I want to have multiple a MySQL users to be able to issue commands like
CREATE DATABASE dbTest;
But I also want each of these users to be able to see and access only their own databases.
All I could find was how to either create the databases by a DBA and grant the privileges on this database to the specific user:
GRANT ALL PRIVILEGES ON dbTest.* TO 'user';
or grant privileges on all databases to a user:
GRANT ALL PRIVILEGES ON *.* TO 'user';
But neither is what I want, because it needs to scale and be secure.
mysql> CREATE USER 'linuxconfig'@'localhost' IDENTIFIED BY 'password_here'; Now it is time to grant permissions to our linuxconfig user so that it can create new databases. We will do this by granting them the CREATE permission with the following command. mysql> GRANT CREATE ON *.
You can use
GRANT ALL PRIVILEGES ON `testuser\_%` . * TO 'testuser'@'%';
to grant the user testuser
privileges on all databases with names beginning with testuser_
.
This allows the testuser to create databases limited to names starting with testuser_
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With