How to install MariaDB on Ubuntu

MariaDB database management system is a branch of MySQL, mainly by the open-source community in the maintenance, using GPL license. MariaDB is designed to be fully compatible with MySQL, including API and command line.

This post describes the installation of MariaDB on Ubuntu, although it is quite simple.

Install the MariaDB database and the console client for the database from the Ubuntu repositories:

sudo apt install mariadb-server mariadb-client

By default, MariaDB does not have an administrative user with a password, so there are two options:
  1. add a user with a full set of rights;
  2. add root password and log in the ability to the user.

User Adds

Manually add a new user as root and run the client for the database.

mariadb

Create an ordinary user with all rights and password authentication.

CREATE USER ‘ddos’@’localhost’ IDENTIFIED BY ‘Dvs@$)$’;

Parameter:

  • Username: ddos
  • Password: Dvs@$)$
Assign maximum privileges to the created user.
GRANT ALL PRIVILEGES ON *.* TO ‘ddos’@’localhost’;
Apply the changes:

FLUSH PRIVILEGES;

Exit the console client:

EXIT;

Add a password for the root user

For database configuration, there is a mysql_secure_installation script that allows you to perform initial database configuration.
Run this script:
mysql_secure_installation
It is required to enter the current password of the root user (by default it is empty, so just press Enter):
Enter current password for root (enter for none):
Do I need to set a password for the root user (press Y and Enter):
Set root password? [Y/n]
Next, we will be asked to provide a new password for the root user.
Remove connectivity for anonymous users (press Y and Enter):
Remove anonymous users? [Y/n]
Deny remote login for root user (press Y and Enter):
Disallow root login remotely? [Y/n]
Delete the test base: (press Y and Enter):
Remove test database and access to it? [Y/n]
Update privileges (press Y and Enter):
Reload privilege tables now? [Y/n]
After setting up the script, you need to connect to the database via the socket (as root):
mariadb
Remove authentication via socket:
use mysql;
UPDATE `user` SET `plugin` = NULL WHERE `user`.`Host` = ‘localhost’ AND `user`.`User` = ‘root’;
Apply the changes:
FLUSH PRIVILEGES;
Exit the console client:
EXIT;