How To Create a New User and Grant Permissions in MySQL

How to Create a New User

Let’s start by making a new user within the MySQL shell:

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

At this point newuser has no permissions to do anything with the databases. In fact, even if newuser tries to login (with the password, password), they will not be able to reach the MySQL shell.

Grant Permissions

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

Flush

FLUSH PRIVILEGES