When you need to restrict users to a specific database do this….
log in as a/the admin user:
mysql -u root -h localhost -p
(enter your password)
then run these commands:
CREATE Database databasename;
CREATE USER ‘username’@’%’ IDENTIFIED BY ‘password’;
REVOKE ALL PRIVILEGES,GRANT OPTION from ‘username’@’%’;
GRANT ALL ON databasename.* TO ‘username’@’%’;
Line 1 creates a database named: databasename (mmmm… insert the database name you want here)
Line 2 creates a user named username and gives them a password
Line 3 Takes a way all username privileges
Line 4 gives username all privileges on all the tables in databasename
MySQL User Restrictions
Jun, 13 -- Categories: MySQL