Create a New User and Grant Permissions in MySQL

In Part 1 of the MySQL Tutorial, we did all of the editing in MySQL as the root user, with full access to all of the databases. However, in cases where more restrictions may be required, there are ways to create users with custom permissions.

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

 

mysql> CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;

mysql>RANT ALL PRIVILEGES ON * . * TO newuser@‘localhost’;

mysql>FLUSH PRIVILEGES;