Skip to main content

Database Service

First, update the system, install the database manager and check that it is running:

on your remote SSH session:
sudo apt update
sudo apt full-upgrade
sudo apt install mariadb-server
sudo systemctl status mariadb

Open MariaDB shell and set up the database

on your remote SSH session:
sudo mariadb

Once in the MariaDB environment, follow the next steps:

-- Create your database:
CREATE DATABASE yourdatabase;

-- Optionally, you can check newly created database:
SHOW DATABASES;

-- Provide admin credentials to an user and reload the cache:
GRANT ALL PRIVILEGES ON yourdatabase.* TO "youruser"@"localhost" IDENTIFIED BY "yourpassword";
FLUSH PRIVILEGES;

-- Optionally, you can query the users and their privileges:
SELECT User FROM mysql.user;
SHOW GRANTS FOR "youruser"@"localhost";

-- exit MariaDB:
EXIT;

Secure the installation with the following script:

on your remote SSH session:
sudo mysql_secure_installation

after which you will need to change the way you invoke the MariaDB environment to:

on your remote SSH session:
mariadb -u youruser -p

In one of the next chapters you will benefit of the PHP programming language to install an useful web tool to administer your MariaDB databases.