How to create an user in MySQL command line

To create a new user on your MySQL server, start the `mysql` command line client and execute the following query:

CREATE USER 'cb'@'localhost' IDENTIFIED BY 'secretPassword';

This will create an user named ‘cb’, which is allowed to access from ‘localhost’ clients and having a password – ‘secretPassword’.

To grant this user access to some database check the “Grant user access to a database in MySQL command line”.

Follow our blog for more MySQL related articles.