Creating A MySQL User
1
CREATE USER 'user_name'@'host_name' IDENTIFIED BY 'password';
Granting a User Permissions
Permissions are actions that the user is allowed to perform in the database.
1
GRANT ALL PRIVILEGES ON 'database_name'.* TO 'user_name'@'host_name'.
If you want to give permissions to a particular table
1
GRANT PRIVILEGE ON database_name.table_name TO 'user_name'@'host_name';
If you want to give a particular permission
All Privileges: The user account has full access to the database
Insert: The user can insert rows into tables
Delete: The user can remove rows from tables
Create: The user can create entirely new tables and databases
Drop: The user can drop (remove) entire tables and databases
Select: The user gets access to the select command, to read the information in the databases
Update: The user can update table rows
Grant Option: The user can modify other user account privileges.
1
GRANT permission_type ON database_name.table_name TO 'user_name'@'host_name';
For Example, if you want to give the INSERT permission.
1
GRANT INSERT ON *.* TO 'user_name'@'host_name';
Revoke Privileges MySQL User Account
1
REVOKE ALL PRIVILEGES ON database_name.* FROM 'database_user'@'host_name';
Remove an Existing MySQL User
1
DROP USER 'user'@'localhost'
How to check MySQL User Account-Privileges
1
SHOW GRANTS FOR user_name;
Blog : https://phpgurukul.com/how-to-create-a-mysql-new-user-and-grant-permissions-in-linux/