Pre requirement: Before we get started with the MariaDB server make sure you have installed the MariaDB Server and enabled it in systemctl before you proceed to read this article.
OS Version: Ubuntu Os 18.04.3 (LTS) x64
MariaDB Version: 10.1.44
Login to mariadb server:
bluegrid-edu:~# mysql

Create database:
MariaDB [(none)]> create database edudb;
Create user who’d be accessing your new database:
MariaDB [(none)]> create user [email protected] identified by 'topsecretpassword';
Let’s ensure that our new user “edu” will have all privileges accessing database “edudb”:
MariaDB [(none)]> grant all privileges on edudb.* to [email protected];
ALWAYS reload privileges for the changes to take effect:
MariaDB [(none)]> grant all privileges on edudb.* to [email protected];
Now, let’s check if we can log in to MariaDB Server with password topsecretpassword
:
- Logout from current session:
MariaDB [(none)]> quit
- Login to Mariadb Server:
bluegrid-edu:~# mysql -uedu -p

Since we have defined that this user has all privileges to database “edudb” only we should be able to see only this database in the list:
MariaDB [(none)]> show databases;

Related articles: Getting started with Mariadb – Create Table