I want to create a new user in MySQL and give it full access only to one database, say dbTest, that I create with a command like create database dbTest;. What would be the MySQL commands to do that?
I want to create a new user in MySQL and give it full access only to one database, say dbTest, that I create with a command like create database dbTest;. What would be the MySQL commands to do that?
To me this worked.
CREATE USER 'spowner'@'localhost' IDENTIFIED BY '1234';
GRANT ALL PRIVILEGES ON test.* To 'spowner'@'localhost';
FLUSH PRIVILEGES;
where
In case the host part is omitted it defaults to the wildcard symbol %, allowing all hosts.
CREATE USER 'service-api';
GRANT ALL PRIVILEGES ON the_db.* TO 'service-api' IDENTIFIED BY 'the_password'
SELECT * FROM mysql.user;
SHOW GRANTS FOR 'service-api'