Login as database administrator
Code:
mysql> grant all on dba.* to 'wim'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for 'wim'@'localhost';
+-----------------------------------------------------------------------------------+
| Grants for wim@localhost |
+-----------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'wim'@'localhost' IDENTIFIED BY PASSWORD '571c3ced13511691' |
| GRANT ALL PRIVILEGES ON `dba`.* TO 'wim'@'localhost' |
| GRANT ALL PRIVILEGES ON `btd_budget`.* TO 'wim'@'localhost' |
| GRANT ALL PRIVILEGES ON `btd_documents`.* TO 'wim'@'localhost' |
| GRANT ALL PRIVILEGES ON `cc_rfs`.* TO 'wim'@'localhost' |
+-----------------------------------------------------------------------------------+
5 rows in set (0.00 sec)
mysql> exit
Bye
Please note that database dba does not have to exist yet.
Login as user wim and create the database
Code:
mysql> create database dba;
Query OK, 1 row affected (0.04 sec)
mysql> show databases;
+---------------+
| Database |
+---------------+
| btd_budget |
| btd_documents |
| cc_rfs |
| dba |
+---------------+
4 rows in set (0.00 sec)
mysql>
I'm not a guru, but as far as I know you can not grant permissions to users to generate a number of databases. Either they can create any database (same as the administrator) or they can create predefined ones (as shown above after which the users can create them).
Personally I also don't see a need for it. The administrator should (in my opinion) decide on the databases that a user can create. Point is that you might want to create a db called mydb and I also want to do that. There can however only be one mydb.