Mysql Database creation script

Two days ago one of my client dev’s requested me to be able to create db’s on their MySQL instance.
Of course, I won’t give him the “GRANT GRANT WITH GRANT OPTION” :-P, in that case I will simply give him root password :-P
As i didn’t find anything that solves my problem over Internet, I just did mine, as allways..
Here’s he result.

Prereqs:

  • Create a Mysql user with the following grants:
    [cc lang=”bash”]
    GRANT CREATE, RELOAD, SHOW DATABASES, CREATE USER ON *.* TO ‘database_creator’@’localhost’ IDENTIFIED BY ‘YOUR_PASSWORD’ ;
    GRANT INSERT ON `mysql`.`db` TO ‘database_creator’@’localhost’ ;
    [/cc]
  • That will allow us to create databases, users, make some checks and reload privs, while we don’t create a new “root”…

You can download the script code from the wiki, also you’ll find additional information there.

Follow and Share!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.