- Let’s start by making a new user within the MySQL shell:
mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
Note: When adding users within the MySQL shell in this tutorial, we will specify the user’s host as localhost
and not the server’s IP address. localhost
is a hostname which means “this computer,” and MySQL treats this particular hostname specially: when a user with that host logs into MySQL it will attempt to connect to the local server by using a Unix socket file. Thus, localhost
is typically used when you plan to connect by SSHing into your server or when you’re running the local mysql client to connect to the local MySQL server.
- GRANT PERMISSION
mysql> GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
- FINISH
mysql> FLUSH PRIVILEGES;
More information: https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql