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 ...
Get Getting Started with MariaDB - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.