How to create new user MySQL?

The open-source, highly popular database is MySQL. MySQL database helps to store, organize, and retrieve data. It has quite a lot of options to grant permission.

In this post, we are going to talk about how to create a new user and how to grant them permissions.

Let’s first login to the MySQL server and try the following command:

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

Now try to grand the access using the following command:

mysql> GRANT ALL PRIVILEGES ON databasename.* To 'user'@'hostname'

Now flush the privileges

mysql> FLUSH PRIVILEGES;
Reference: