How to install MariaDB on CentOS, Debian & Ubuntu?

install Maria DB on Centos ,Debian & Ubuntu


The MariaDB is an open source relational database management system is an enhanced, drop-in replacement for MySQL database technology.

It turns data into structured information in a wide array of applications, ranging from banking to websites. MariaDB is used because it is fast, scalable and robust, with a rich ecosystem of storage engines, plugins and many other tools make it very versatile for a wide variety of use cases.

Install MariaDB in CentOS

Please refer the following steps to install in the MariaDB in the Centos server.

  1. First, you need to add the MariaDB repo file in the server YUM repository file.

vi /etc/yum.repos.d/MariaDB.repo

name = MariaDB
baseurl =

2. Install the MariaDB using following command from the server command line.

yum install MariaDB-server MariaDB-client -y

command to install MariaDB on centOS

3. Once the installation is done, we need to start the database server daemon and enable it to start automatically at the next boot. Please find the following commands.

# systemctl start mariadb

# systemctl enable mariadb

mariaDB installation on centOs

# systemctl status mariadb

MariaDB installation

Secure your MariaDB

Once the MariaDB initiation is done, you need to secure it. Please refer the following command

# mysql_secure_installation

Command to secure mariaDB
Secure your MariaDB 1

4. Login to the MariaDB via Command line using the following command

# mysql -u root -p

MariaDB login command

MariaDB on Debian and Ubuntu 

 Installation guide steps

  • Update your package index using apt.
  • Install the mariadb-server package using apt. The package also pulls in related tools to interact with MariaDB.
  • Run the included mysql_secure_installation security script to restrict access to the server.

sudo apt-get install software-properties-common
$ sudo apt-key adv –recv-keys –keyserver

$ sudo add-apt-repository ‘deb [arch=amd64] stretch main’

  1. Update the system packages sources list

sudo apt update

Then install the MariaDB server:

sudo apt install mariadb-server

2. Verify MariaDB installation

sudo systemctl status mariadb

[email protected]# sudo systemctl status mariadb
mariadb.service – MariaDB 10.3.15 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-09-22 20:35:29 UTC; 47min ago
Docs: man:mysqld(8)
Main PID: 2036 (mysqld)
Status: “Taking your SQL requests now…”
Tasks: 30 (limit: 2378)
Memory: 76.1M
CGroup: /system.slice/mariadb.service
└─2036 /usr/sbin/mysqld

deb-mariadb1 /etc/mysql/debian-start[2074]: Phase 6/7: Checking and upgrading tables
deb-mariadb1 /etc/mysql/debian-start[2074]: Running ‘mysqlcheck’ with connection arguments: –socket=’/var/run/mysqld/mysqld.sock’ —
host=’localhost’ –socket=’/var/run/mysqld/mysqld.sock’ –host=’localhost’ –socket=’/var/run/mysqld/mysqld.sock’
deb-mariadb1 /etc/mysql/debian-start[2074]: # Connecting to localhost…
deb-mariadb1 /etc/mysql/debian-start[2074]: # Disconnecting from localhost…
deb-mariadb1 /etc/mysql/debian-start[2074]: Processing databases
deb-mariadb1 /etc/mysql/debian-start[2074]: information_schema
deb-mariadb1 /etc/mysql/debian-start[2074]: performance_schema
deb-mariadb1 /etc/mysql/debian-start[2074]: Phase 7/7: Running ‘FLUSH PRIVILEGES’
deb-mariadb1 /etc/mysql/debian-start[2074]: OK
deb-mariadb1 /etc/mysql/debian-start[2132]: Triggering myisam-recover

If MariaDB services is not running properly, the please use the following command to start it

sudo systemctl start mariadb

3. Secure MariaDB

sudo mysql_secure_installation

4. Login to the MariaDB via Command line using following command

# mysql -u root -p

[email protected]# mysql -u root -p
mysqladmin Ver 9.1 Distrib 10.3.15-MariaDB, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Server version 10.3.15-MariaDB-0+deb9u1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 1 hours 44 min 46 sec

Threads: 1 Questions: 36 Slow queries: 0 Opens: 21 Flush tables: 1 Open
tables: 15 Queries per second avg: 0.003

MariaDB [(none)]>


Leave a Reply