“MariaDB is an open-source, relational database management system (RDBMS). The MariaDB client allows you to add new users and grant them different degrees of privileges with ease.
To learn more about MariaDB, check this out:
Today, we will explore how to create a MariaDB user and grant them full privileges. Make sure you have a running instance of MariaDB where you have a user account with sudo privileges.”
Guide
Step 1: Access MariaDB Server
First, we need to access the MariaDB server client shell. To do that, execute the following command:
If you have set the password for your root account, run the following command and then enter the password to get access.
If you have not created any database yet, you can create one using the following command:
To see the list of the existing databases, issue the following command:
This will show you the database you just created.
Step 2: Create a New MariaDB User
In this step, we will create a new MariaDB user. To do that, run the following command:
Make sure to enter your username and password in place of DBuser and password123.
You can check the status of the user by running the following command:
The output will present you with a list of all the existing users.
Step 3: Grant Privileges to MariaDB User
The user you created doesn’t have privileges to interact with databases. We need to grant it all privileges with the help of the following command:
If you wish to grant privileges only to your database, run this command:
Refresh the privileges with this command:
To verify the right permissions you just granted to the user, run this command:
Step 4: Remove MariaDB User Account
In case you want to remove a user, you can use the following command:
After running this command, your user will no longer have access to the database.
Conclusion
In today’s guide, we saw in detail how to create a MariaDB user and grant them full user privileges. We explored multiple MariaDB commands to interact with the database. In the end, we also had a look at how to remove a user.
We hope you liked the tutorial.