How to Create User and Grant Privileges in Mariadb

How to Create User and Grant Privileges in Mariadb?

Asked on August 30, 2021 in info.
Add Comment
1 Answer(s)

To create a user and grant privileges to the databases, run the commands as shown:

#Create user mariadb
MariaDB [(none)]> CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';

#Grant all privileges to the user
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'localhost' IDENTIFIED BY 'mypassword';

#Grant privileges to a specific database
MariaDB [(none)]> GRANT ALL PRIVILEGES ON 'DB1'.* TO 'user1'@'localhost';

#Remember to refresh the privileges
MariaDB [(none)]> FLUSH privileges;

#To check user grants in MariaDB
MariaDB [(none)]> SHOW GRANTS FOR 'myuser'@'localhost';
Answered on August 30, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.