How to Create a MariaDB user, password and database on CentOS Linux

In this tutorial, we will create a database along with a user to access the database.

For the purpose of this tutorial, we will assume that you have already installed MariaDB on CentOS Linux.

1. Log in to the MariaDB console. If you have a password set, use the -p flag to enter a password.

mysql -u root

2. Create a database, named “testdb” – we will use the utf8mb4 character set (see: “Never use utf8. Use utf8mb4.”)

create database testdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

3. Grant user “testuser”, with password “testpassword” all access to the “testdb” database. Note: if you want to remotely access this database, replace ‘localhost’ with your remote address.

grant all privileges on testdb.* to testuser@'localhost' identified by 'testpassword';

4. Flush MariaDB privileges

flush privileges;

Your database will now be ready to use!

Scan to Donate Bitcoin
Like this? Donate Bitcoin to at:
Bitcoin 13KzxfEoFPzt5ccoQvSkUEytTgQV8JN5ej
Share This Post

About Author: Curtis K

Hi! My name is Curtis, and I am the author of CentOS Blog. Please feel free to comment with any suggestions, feedback or questions!