External database connection

I want to be able to use hestiacp just to create a mysql database and be able to consume these databases externally using the host/ip of my server, I checked on the server and noticed that port 3306 is not open for this type of connection, in the panel can hestia release?, I’ve tried to add a rule to this port and it had no effect.

PORT     STATE  SERVICE
3306/tcp closed mysql

Hello @apollo333,

First of all, you should be really careful about opening mysql to the world, you should grant remote permissions only for some users and some ips or you could have security issues.

You can’t connect to mysql because by default it only listens on localhost (127.0.0.1) so doesn’t matter the firewall rule you have added, mysql is not listening there.

If you want mysql listening on all your ips, modify directive bind-address in file /etc/mysql/mariadb.conf.d/50-server.cnf (I’m showing and example because I’m using MariaDB so in your installation could be in another file):

Change this:
bind-address = 127.0.0.1

to this:
bind-address = "*"

Edit: just to clarify, if you use "*" it will listen on all ips (IPv4 and IPv6). If you only want to allow IPv4 use 0.0.0.0 instead of "*"

bind-address = 0.0.0.0

And restart mysql.

systemctl restart mysqld.service

Good luck,
sahsanu

5 Likes

if I put the ip of the connection destination only it will be able to have connection permission?

Usually, the db users are only allowed to connect from localhost so you should grant privileges to that user and to that db from the external ip (or from all ips… but that is a security risk).

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.