## Table of Contents
– [Install MariaDB on Debian 9](#install-mariadb-on-debian-9
– [Install MariaDB](#install-mariadb
– [Configure MariaDB](#configure-mariadb
– [Adjust User Authentication and Privileges – Optional](#adjust-user-authentication-and-privileges-optional
– [Test MariaDB](#test-mariadb
In this guide, we are going to explain to you how to install MariaDB on Debian 9 and some additional recommended steps that you must take to increase the usability and security of your server.
[MariaDB](https://mariadb.org/ is one of the most popular database servers in the world. It is an open-source database management system, developed by the MySQL developers as a replacement for MySQL. Debian 9 prefers MariaDB, which is developed by the MySQL developers as a replacement for MySQL. MariaDB is the default MySQL variant on Debian 9. So, if you want MySQL installation for reference, follow our guide, [How to Install the Latest MySQL on Debian 9](https://systemongrid.com/support/guides/how-to-install-the-latest-mysql-on-debian-9. Between MySQL and MariaDB, [MariaDB is the preferable package and can work better](https://mariadb.com/kb/en/library/mariadb-vs-mysql-compatibility/.
Before installing MariaDB on Debian 9, you should have access to the Debian server and created a non-root user account with sudo privileges by following our guide, [Initial server setup with Debian 9](https://systemongrid.com/support/guides/initial-server-setup-with-debian-9.
## Install MariaDB on Debian 9
## Install MariaDB
Before installing MariaDB, you need to update the packages on your server.
$ sudo apt update
Then, install the MariaDB package.
$ sudo apt install mariadb-server
## Configure MariaDB
Now, it is time for you to secure the MariaDB server. It uses a security script to modify the default security options like remote logins. Use the below command to run the security script.
$ sudo mysql_secure_installation
Then, you will be asked to enter the root password and if you want to change the root password. Since you already have a root password, you can answer “n”.
Then, you will be asked if you want to remove anonymous users. Press Y for yes, or any other key to continue. (We recommend accepting all the below security suggestions by entering “Y” in each step.
Then, you will be asked if you want to disallow root login remotely. Press Y for yes, or any other key to continue.
Then, you will be asked to remove the test database and reload privilege tables. Press Y for yes, or any other key to continue.
Finally, you will get the following output.
## Adjust User Authentication and Privileges – Optional
Instead of modifying the root account, it is highly recommended to create a new user with root privileges for administrative tasks and password-based access.
To do so, open the MariaDB prompt.
$ sudo mysql
Use the below command to create a new user. Replace the user name and password to match your details.
MariaDB [(none]> GRANT ALL ON *.* TO ‘systemongrid’@’localhost’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;
Now, run the below command to make your changes effective.
MariaDB [(none]> FLUSH PRIVILEGES;
Then, exit the MariaDB Prompt.
MariaDB [(none]> exit
## Test MariaDB
You have installed and secured the MariaDB. Now, its time for you to test the MariaDB.
For that, check the status of the MariaDB database server.
$ sudo systemctl status mariadb
The above output shows that the MariaDB database server is active and running.
You can also test your MariaDB installation and know the information about it. For that, you need to connect to your MariaDB server as root user (or, a user with password authentication using the below command.
$ mysqladmin -u systemongrid -p version
The above output shows that the MariaDB installation has been successful.
In this guide, you have learned how to install MariaDB on Debian 9 and some additional steps that must be taken to increase the usability and security of your server.