Creating users
Creating a user in MariaDB involves a two-step process. First, we create the user using the CREATE USER
statement, and then we give or GRANT
the user the privileges that we want them to have. We'll go over the CREATE USER
statement in this section and the GRANT
statement in the granting, revoking, and showing permissions section.
A CREATE USER
statement has the following pattern:
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
We customize the username
, host
, and password
parts to the appropriate values. If we don't want to specify a password (though this is not recommended!) then we can drop the IDENTIFIED BY 'password'
part. This, and all the other SQL statements that we input into MariaDB, need to end with a semicolon (;
).
The host part can be several things. It can be the hostname of the computer which the user connects from, the IP address of the computer that the user connects from, the network that the user connects...