How To Create a New User in MySQL 8

November 27th, 2020

Warning: This post is 3 years old. Some of this information may be out of date.

The way new users are created on MySQL changed with version 8.
In previous versions you could create a new user with the GRANT option:

# MySQL 5.7
GRANT ALL ON my_database.* TO 'user'@'127.0.0.1' IDENTIFIED BY 'its-a_secret'

Here's how to create a new user in MySQL 8:

# MySQL 8
CREATE USER 'user'@'127.0.0.1' IDENTIFIED BY 'its-a_secret';
GRANT ALL ON my_database.* TO 'user'@'127.0.0.1';