How To Create a New User in MySQL 8

Image for How To Create a New User in MySQL 8 from unsplash.com

By Andrew McCombe
November 27, 2020


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';