title: mysql: database specific user permission delegation with grant option and wildcard
body: <p>I want to have a non-root mysql user that can create another databases and users and grant access to that users to created databases. To do this as <b>root</b> I firstly created a user</p>
  
  <pre><code>CREATE USER asusi_admin@localhost IDENTIFIED BY '123';
  </code></pre>
  
  <p>Then I grant create user PRIVILEGE to this user</p>
  
  <pre><code>GRANT CREATE USER ON *.* TO 'asusi_admin'@localhost';
  </code></pre>
  
  <p>Then I grant all privileges to this user for the every database he creates</p>
  
  <pre><code>GRANT ALL PRIVILEGES ON `asusi\_%`.* TO 'asusi_admin'@'localhost WITH GRANT OPTION;
  </code></pre>
  
  <p>Now I'm flushing privileges</p>
  
  <pre><code> FLUSH PRIVILEGES;
  </code></pre>
  
  <p>Now I'm logging on to MySQL as newly created user <b>asusi_admin</b> and creating a new database</p>
  
  <p>Now I'm creating a new database </p>
  
  <pre><code> CREATE DATABASE asusi_database;
  </code></pre>
  
  <p>Now I'm checking that I can use this database</p>
  
  <pre><code> USE asusi_database;
  </code></pre>
  
  <p>I can use this database, good</p>
  
  <p>Now I'm creating a new user</p>
  
  <pre><code>CREATE USER 'asusi_user'@'localhost' IDENTIFIED '123';
  </code></pre>
  
  <p>Now I want to grant select privilege to the created user</p>
  
  <pre><code>GRANT select on `asusi_database`.* 'asusi_user'@'localhost'
  </code></pre>
  
  <p>And here I'm getting an error: <i>'Access denied for user 'asusi_admin'@'localhost' to database 'asusi_superdb'</i> </p>
  
  <p>Should I relogin as <b> root </b> and explicitly grant access to this database to a <i>asusi_user</i></p>
  
  <pre><code>GRANT ALL PRIVILEGES ON `asusi_database`.* TO 'asusi_admin'@'localhost WITH GRANT OPTION; 
  </code></pre>
  
  <p>and then relog in as <b> asusi_admin </b> and run the command again </p>
  
  <pre><code>GRANT select on `asusi_database`.* 'asusi_user'@'localhost'
  </code></pre>
  
  <p>this time it gives me no error and user <i>asusi_user</i> can read database <i>asusi_database</i>. Apparently MySQL wants me to explicitly grant access to the user <i> asusi_admin </i> for the every created database via <i>root</i> account. But I don't want to use the <i>root</i> account. I thought that after executing this command </p>
  
  <pre><code>GRANT ALL PRIVILEGES ON `asusi\_%`.* TO 'asusi_admin'@'localhost WITH GRANT OPTION;
  </code></pre>
  
  <p>user <i>asusi_admin</i> will be able to grant access to other users to the ecery database that stats with 'asusi_' prefix. May be I missed something or this behavior is designed to be that way?</p>