How to Enable Remote Access to MariaDB Database Server on AlmaLinux 8

Previous: How To Setup MariaDB Database Server On AlmaLinux 8

a) Configuring

Edit the /etc/my.cnf.d/mariadb-server.cnf file on your favorite text editor with superuser privileges. Suppose, you want the MariaDB server to listen on address, on port 12345. Under the file’s mysqld section, add or edit the lines below.


port=12345 means all available IP addresses including localhost. If you want to bind only one IP address, you should write that one instead of the address. If the port is not mentioned, the server will listen on its default port 3306.

b) Restarting

Restart the mariadb service.
sudo systemctl restart mariadb.service

c) Adding Port To SELinux Policy Configuration

You should add the port to the policy configuration of the SELinux (Security Enhanced Linux).
sudo semanage port -a -t mysqld_port_t -p tcp 12345

d) Making FirewallD to Allow

You may have to add the port to the FirewallD‘s allow list.
sudo firewall-cmd --zone=public --permanent --add-port=12345/tcp
Then reload the firewalld.
sudo firewall-cmd --reload

Next: How To Grant Remote Login Privilege To A MariaDB User Account


Abdullah As-Sadeed
Abdullah As-Sadeed

Prefers coding from scratch. Loves the Linux kernel.

Leave a Reply