installMariaDB Debian

How to Install MariaDB in Debian?

At one time, the MySQL DBMS switched on a commercial basis, unwittingly enabling the interested part of the community to create an offshoot based on the free source code. So the MariaDB project was created, which is carried out by enthusiasts from around the world. It has absolute similarity with MySQL, but includes many improvements. This article describes how to install MariaDB in Debian GNU/Linux.

Please note: if you are not working on behalf of the superuser, use the sudo command to perform the required operations in the terminal. Also, if you have an active MySQL DBMS, disable it before starting.

Installing MariaDB in Debian

The main convenience of this DBMS is that in most GNU/Linux distributions it comes in standard repositories. And Debian is not an exception, as this software is great for server-side tasks.

Installs MariaDB as follows:

yes | apt install mariadb-server

The package manager will immediately determine what additional components are still needed for the minimum, but full-fledged operation of the DBMS, and will offer to download them as well.

debian mariadb

To check its program status, input:

/etc/init.d/mysql status

debian install mariadb

Don’t be confused by a query to mysql, not mariadb. It happened historically that in many places of the system mysql is used as an alias for mariadb. However, that’s why you should first disable the installed (if any) MySQL.

To enable MariaDB, type:

/etc/init.d/mysql start

install mariadb on debian

The complete list of commands for controlling the daemon can be viewed as follows:

install mariadb on debian 9

You can also manage daemons using systemd, namely systemctl.

systemctl {start|restart|stop|reload} mariadb

Setting up MariaDB

The next step is to run the DBMS security configuration script. It performs:

  • setting a password for root;
  • disabling remote authorization as root;
  • removal of anonymous user accounts;
  • removing a test DB that is available to anonymous users.

To start it, input:

sudo mysql_secure_installation

Next, answer the questions in the affirmative (just press Enter). First, after the first question, set the password for the root user of the database. The whole process will take several seconds.

install mariadb debian 8

Now you can log in mariadb as root. If a login error occurs at this point

debian 8 install mariadb

then write the commands:

sudo mysql

use mysql;

update user set plugin='' where User='root';

flush privileges;


You should also set the encoding UTF-8 as default. This will allow you to correctly display any text information from the database, regardless of language. To do this, open the file /etc/mysql/my.cnf in editor (for example, in nano):

sudo nano /etc/mysql/my.cnf

and add the following text at the end:


init_connect=‘SET collation_connection = utf8_unicode_ci’

character-set-server = utf8

collation-server = utf8_unicode_ci


default-character-set = utf8

Save the changes and close the editor. It remains to restart the daemon:

sudo /etc/init.d/mysql restart

This completes the installation and configuration of MariaDB on Debian.

Add Your Comment