Home / Blog / Post
How To Administer User Accounts In Mysql
Added on 29th January 2019 in Snippet

When working with a mysql database, you may need to add additional users for many reasons, following is a selection of commands to do this simply.

Change username password,database_name and table_name to the real values.

Create a User

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Add All Privileges

GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';

Reload Privileges


Add Specific Permission

GRANT type_of_permission ON database_name.table_name TO ‘username’@'localhost’;

Remove Specific Permission

REVOKE type_of_permission ON database_name.table_name FROM ‘username’@‘localhost’;

Delete User

DROP USER ‘username’@‘localhost’;

Show Permissions

SHOW GRANTS username;

Hi there, I am christopher shaw, a software developer form South Yorkshire, England.

I love tinkering with all things tech, and opened this website as a web presence for myself and a place to keep my notes and snippets. Hopefully you will find something here to help

Christopher Shaw