
How to Create MySQL User
• July 3, 2025
mysqlMySQL is a popular relational database management system, and in this post, I will show you how to create a MySQL user. When you first install MySQL on your computer, by default, it comes with a root user who has all privileges in the DBMS. It is recommended to create another user who those not have the same root-level access as the root user does.
To create a MySQL user, you can simply put the following command in your MySQL shell.
CREATE USER 'john'@'localhost' IDENTIFIED BY 'password';
The command above will create a new user named John. The next step is to give John some privileges in the DBMS.
GRANT PRIVILEGE ON database.table TO 'john'@'localhost';
The GRANT command allows you to control John's access. If you want to create another root user, then you would have to do the following.
GRANT ALL PRIVILEGES ON *.* TO 'john'@'localhost' WITH GRANT OPTION;
This command will effectively give John the same permissions as the root user. The above command is not recommended. With the commands above, you can create and grant privileges to a MySQL user. The next thing is to change or modify our created user.
ALTER USER 'john'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';
The above command changes John's password and the default authentication plugin. If you don't want to change the default authentication plugin, then you can always omit the WITH mysql_native_password
.