How to Create User and Grant Privileges in Mariadb
How to Create User and Grant Privileges in Mariadb?
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';