how do I grant a new user the privilege to create a new database in MySQL
Specifically:
- the database does not exist yet
- I have successfuly created a new DB user account (that is not admin)
- I want that non-admin user to create a new database
- I do NOT want the 'admin' user to create the database and then grant privs to the database to the new user
- as 'admin', I want to grant the new user the privilege to create a new database
- I do not want to grant the new user any additional privileges on existing databases
This is not covered anywhere in the documentation that I can find.
Monday 2022-04-04 Update:
I created user 'scott' and then logged in as MySQL user 'admin' When I run this command
Note: The 'test' database does not yet exist
mysql>GRANT CREATE ON test.* to 'scott'@'localhost';
I get an error ==> ERROR 1410 (42000): You are not allowed to create a user with GRANT
Why do I get this error? I am not attempting to create a user, but rather grant a user access to a non-existent database (as is the approach with MySQL to grant a user privileges to create a database).
If up update the SQL statement to: mysql>GRANT CREATE ON test.* to scott;
It runs OK Query OK, 0 rows affected (0.07 sec)
And so now I login as user 'scott and run this statement:
mysql>create database rum;
==> ERROR 1049 (42000): Unknown database 'test'
Why do I get this error?
At this point, I am still not able to create a database as a non-admin user.