How to Listen to All Available Network Interface for incoming MariaDB Database Request

Posted on

Introduction

By default, MariaDB as a database service will run by listening to any incoming request or connection to the interface. The one available for the listening interface is only the local interface. That local interface is the ‘127.0.0.1’ or normally as ‘localhost’ as an alias. So, how is the MariaDB, the database itself can actually listen and accept for all available interfaces in the server ?. The answer is quite simple. Just modify the MariaDB database configuration file. But there is a need to look out for the actual configuration file. Basically, the main configuration exist in ‘/etc/my.cnf’. But since it is a MariaDB database server, there is another file exist. It exist in the following information exist in the ‘/etc/my.cnf’ :

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

There are another configuration file exist in the following directory of ‘/etc/my.cnf.d’. The following is the list of the available configuration file of the databases :

[root@localhost my.cnf.d]# ls -al
total 24
drwxr-xr-x.  2 root root   67 Oct 11 16:02 .
drwxr-xr-x. 77 root root 8192 Oct 11 16:34 ..
-rw-r--r--.  1 root root  295 Apr 26 12:37 client.cnf
-rw-r--r--.  1 root root  232 Apr 26 12:37 mysql-clients.cnf
-rw-r--r--.  1 root root  803 Oct 11 16:02 server.cnf
[root@localhost my.cnf.d]# 

After checking all of the available configuration files. The configuration is actually exist in the file with the name of ‘server.cnf’. The deciding factor for the line of the configuration exist in the following one :

# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
[mariadb-5.5]

Solution

So, according to the previous information, there are two section of MariaDB. It is pointing out each of it for each different version. In order to configure the right version of MariaDB database server, just execute the following command to check the version of the MariaDB database server first :

[root@localhost my.cnf.d]# mysql --version
mysql  Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1
[root@localhost my.cnf.d]# 

Since it has the version of 5.5.64, it is obvious to put the configuration in the mariadb-5.5 section. Just put the following line in the [mariadb-5.5] section :

[mariadb-5.5]
bind-address = *

Just restart the MariaDB database server to implement the change of the configuration above :

[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# 

After restarting the MariaDB database server, check the status of the listening interface for receiving incoming request. Just type the following command :

[root@localhost ~]# netstat -tulpn | grep 3306 
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      27681/mysqld        
[root@localhost ~]#

As in the output of the above command execution, it is obvious that it is currently listening in any available interface in the machine. The representation is in the address of ‘0.0.0.0’. It is currently listening in the default port of MariaDB server. It is listening in port 3306.

Leave a Reply