This tutorial explains how to use the MySQL CREATE USER statement with syntax and examples.
The CREATE USER statement creates a database account that allows you to log into the MySQL database.
The syntax for the CREATE USER statement in MySQL is:
The name of the database account that you wish to create.
Optional. Whether you specify it or not, the CREATE USER statement will behave the same.
The password to assign to user_name.
Let's look at how to create a user in MySQL using the CREATE USER statement.
For example:
In this example, the CREATE USER statement would create a new user called ao in the MySQL database whose password is 'autumn'.
How can you create more than one user at a time in MySQL? You can use the CREATE USER statement to create multiple users by comma separating each user/password combinations.
For example:
This CREATE USER example would create two users in MySQL. The first user would be called ao with a password of 'autumn', and the second user would be called andersonk with a password of 'summer'.
The examples above displayed a plaintext password. You also have the option of providing the hash value for the password (see the PASSWORD function).
For example:
This CREATE USER example would create a new user called ao in the MySQL database with a hash value of the password.