We add new user accounts, adjust privileges, passwords using MYSQL commands.

With CREATE USER and INSERT commands we can specify the username and host name from where the user connects from. For example, if 'user1' connects from 'myCompany.com' host, the account name would be 'user1@myCompany.com'. Users can have usernames from different hosts and different privileges. These data are stored in 'user grant table'. The new user can be created using:


CREATE USER user1@myCompany.com IDENTIFIED BY myPassword;


  • user1@myCompany.com  is user name and myPassword is the password used for logging in. If the username already exists, the above command gives error.

To allow a username to connect from any host we use "%" wildcard syntax:

CREATE USER admin@'%' IDENTIFIED BY adminPassword;

To create a user name without password use syntax:

CREATE USER user1@myCompany.com;

To create new user using INSERT statement use the syntax as shown below:

INSERT INTO user(host, user, password) VALUES('localhost', 'admin', 'adminPassword');


  • user is the name of GRANT table.
  • host is hostname to which localhost value is assigned.
  • user and password are the columns of user GRANT table where, admin, adminPassword values are assigned.