GRANT command is be used for giving privilege to any user for accessing database.
GRANT PRIVILEGES ON DATABASE OBJECTS TO USER@HOST IDENTIFIED BY ‘PASSWORD’;
For granting privilege to user admin Use:
GRANT ALL PRIVILEGES ON *.* TO ‘admin@localhost’ IDENTIFIED BY ‘secret’;
For specifying the username and password which is used while staring MySQL is:
mysql –h hostname –u username –p password
When you don’t want users to access any other database tables then replace* (as shown below) with database name of that particular user whom you want to limit access to other database tables:
GRANT ALL PRIVILEGES ON ‘store’.* TO ‘admin@localhost’ IDENTIFIED BY ‘secret’;
Run given command with root permission. In the given command ‘store’ correlates to the name of database to which the privileges are assigned.