This MariaDB tutorial explains how to use the MariaDB CREATE USER statement with syntax and examples.
The CREATE USER statement creates a database account that allows you to log into the MariaDB database.
The syntax for the CREATE USER statement in MariaDB is:
user_name IDENTIFIED BY [ PASSWORD ] 'password_value';
Parameters or Arguments
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 MariaDB using the CREATE USER statement.
'fastread.aitechtonic'@'localhost' IDENTIFIED BY 'firstpassword';
In this example, the CREATE USER statement would create a new user called fastread.aitechtonic in the MariaDB database whose password is 'firstpassword'.
Create more than one user
How can you create more than one user at a time in MariaDB? You can use the CREATE USER statement to create multiple users by comma separating each user/password combinations.
'fastread.aitechtonic'@'localhost' IDENTIFIED BY 'firstpassword',
'checkyourmath'@'localhost' IDENTIFIED BY 'secondpassword';
This CREATE USER example would create two users in MariaDB. The first user would be called fastread.aitechtonic with a password of 'firstpassword', and the second user would be called checkyourmath with a password of 'secondpassword'.
Using Hash value for password
The examples above displayed a plaintext password. You also have the option of providing the hash value for the password (see the PASSWORD function).
'fastread.aitechtonic'@'localhost' IDENTIFIED BY '*BAC7C920F2507B848358495F25F1B509C0C5C279';
This CREATE USER example would create a new user called fastread.aitechtonic in the MariaDB database with a hash value of the password.