How to install MariaDB Server on Debian 9 Stretch

Welcome to Debian Tutorial. Today I am going to build a MySQL Server on top of my Debian 9 system. I want to use this server for my spatial database. Well, many people said that MySQL Spatial extension is not stable yet but I think its worth to try. So first of all, I am going to install MariaDB Server on Debian 9. Let’s get started

Steps to install MariaDB Server on Debian 9 

Open Terminal and update your Debian 9 with the following command

Next, install MariaDB Server


Once the installation completed we can continue to do some tweak to our MySQL/MariaDB installation. 

Secure MySQL Installation

Execute this command to start securing the MySQL/MariaDB installation:

Follow on screen wizard. You will need to create new password for MySQL root user.

At this point, our MariaDB Server is ready for use. Now we can continue to create a new MariaDB user and new database. We will also configure our MariaDB so it can be accessed remotely. In other words, we will configure remote access to our MariaDB installation. 

Create New MySQL/MariaDB user

Follow these steps to log in and create a new user. From the Terminal, use the following command to log in to MySQL. 

You will need to enter the MySQL root password to continue. Now let’s create a new MySQL user. 

The command will create a new MySQL user called dhani, with password 12345

Create New MySQL Database

Now, let’s create a new database. 

It will create a new database called manjaro. Now let’s grant privileges for dhani to manjaro database.

Allow Remote Access to MySQL Database

If you are planning to access the MySQL Database from outside server, you will need to do this. First, grant MySQL user to access from any machine, not only localhost. To do so, use this command

Please note the ‘%’ of the command above. 

Now, we need to do one more thing to allow MySQL database to be accessed from the network. I wrote an article on How to enable remote access to MariaDB Server. But I will summarize it here. We will edit the file 50-server.cnf located in /etc/mysql/mariadb.conf.d directory. 

Find the following lines

Change it to

Close the file and restart MariaDB Service

The following picture shows how I connect the MySQL Workbench to MariaDB Database on my Debian 9 Stretch. 

install mariadb server on debian 9

DONE. At this point, we have successfully installed MariaDB Server, create new user and database, enable remote access to our database. Thanks for coming and hope this article is useful for anyone who wants to install Mariadb server on Debian 9 Stretch. 

Be the first to comment

Leave a Reply

Your email address will not be published.