How to Change the Default MariaDB Port on Linux

How to Change the Default MariaDB Port on Linux

Hello colleagues.

In today's article, I will tell you about how to change the default port for connecting to the MariaDB bath database. The MariaDB database uses the TCP/3306 connection port. The port should not be changed at all if it is not necessary.
This article is suitable for database administrators, programmers and engineers.

 

The content of the article:

  1. Check which port is currently in use.
  2. Change the password in the config file.

 

1. Check which port is currently in use.

To check which port is currently in use, run the command:

$. sudo netstat -tlpn | grep mariadb

The screenshot shows that port 3306 is currently in use.

 

You can also check in the database itself, to do this, run the following command in the console:

mysql> SHOW VARIABLES LIKE 'port';

This screenshot also shows that port 3306 is being used.


 

2. Change the password in the config file.

The PORT variable itself is static and therefore cannot be changed dynamically via the SET or SET GLOBAL function. To change, you need to change the port in the configuration file itself and restart the database. The server.cnf configuration file itself is located in the /etc/my.cnf.d directory.

$. vim /etc/my.cnf.d/server.cnf

Add the port 3307 parameter to the file.

Save and close.

 

We restart the database.

 

Now back let's check everything:

$. sudo netstat -tlpn | grep mariadb

mysql> SHOW VARIABLES LIKE 'port';

As you can see in the screenshots, the port has successfully changed.


 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES

MariaDB - ERROR Incorrect definition of table
MariaDB - ERROR Incorrect definition of table
MARIADB
Read more
Mariabackup backup - gzip compression
Mariabackup backup - gzip compression
MARIADB
Read more
Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
MARIADB
Read more