How to install MariaDB on Debian 10

MariaDB is an open source, multi-threaded relational database management system, MySQL is backward-compatible alternatives. MariaDB is the default implementation in Debian MySQL.

This tutorial explains how to install MariaDB on Debian 10.

Debian 10 mounted on MariaDB

As of this writing, the latest version of Debian main MariaDB is available in version 10.3.

As root user or use sudo privileges to perform the following steps to install MariaDB in the Debian 10:

  1. First Update Package Index:

    sudo apt update
  2. Package by running the following command to install MariaDB server and client:

    sudo apt install mariadb-server
    1. MariaDB service will start automatically. To verify it, check the service status:
    sudo systemctl status mariadb

    The output should be as follows:

    ●  mariadb.service - MariaDB 10.3.15 database server 
       Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
       Active: active (running) since Thu 2019-07-11 14:36:28 PDT; 19min ago
         Docs: man:mysqld(8)
               https://mariadb.com/kb/en/library/systemd/
     Main PID: 4509 (mysqld)
       Status: " Taking your SQL requests now... "
        Tasks: 30 (limit: 2359)
       Memory: 78.6M
       CGroup: /system.slice/mariadb.service
               └─ 4509 /usr/sbin/mysqld   

Protection MariaDB

MariaDB comes with a script mysql_secure_installation, it can help you improve the safety of the installation. Run in Terminal:

sudo mysql_secure_installation

You will be prompted to root account password, remove anonymous users, restrict root access on the local computer and delete the test database.

...
Enter current password for root (enter for none):
...
Set root password? [Y/n] Y
New password: 
Re-enter new password: 
...
Remove anonymous users? [Y/n] Y
...
Disallow root login remotely? [Y/n] Y
...
Remove test database and access to it? [Y/n] Y
...
Reload privilege tables now? [Y/n] Y
...
Thanks for using MariaDB!

If selected, the script will reload the privilege tables to ensure that the changes take effect immediately.

All steps will be explained in detail, it is recommended to answer "Y" to all questions.

Authentication method

By default, MariaDB root user unix_socket authentication plug-in that checks for a valid user ID when calling the mysql client tools.

This means that only when invoked mysql command system as root or sudo added to the command to connect to the MariaDB server as root.

In order to improve safety, it is recommended to keep the default authentication plug-ins, and allows only the root user to authenticate via a Unix socket.

If you want to change the classic authentication root authentication, log MariaDB Server:

sudo mysql

Run the following statement to change the authentication plug-ins:

ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_root_passwd';

You can now use the new password to connect to the server MariaDB:

mysql -u root -p

After you change the authentication plug-in also allows you to log in from external programs (such as phpMyAdmin) as root

in conclusion

In this tutorial, we showed you how to install and protect the MariaDB server on Debian 10.

Guess you like

Origin www.linuxidc.com/Linux/2019-08/159877.htm