It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In RegisterIt looks like you're new here. If you want to get involved, click one of these buttons!
This tutorial shows how to allow remote connections to the MySQL/MariaDB server on Ubuntu 18.04. By default, Ubuntu MySQL Server blocks all remote connections. Which prevents us from accessing the database server from the outside.
To enable remote connection of MySQL in Ubuntu server, you will need to edit the MySQL main configuration file.
So if you have installed MySQL Database server configuration file is: /etc/mysql/mysql.conf.d/mysqld.cnf. However, if you are using MariaDB Database server, configuration file going to be /etc/mysql/mariadb.conf.d/50-server.cnf.
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 127.0.0.1
bind-address = 0.0.0.0
By changing value to 0.0.0.0, we instruct MySQL to bind to all available interfaces and by doing that we allow remote connections to the MySQL Server on Ubuntu 18.04.
For MySQL: sudo systemctl restart mysql
For MariaDB: sudo systemctl restart mariadb
For MySQL: sudo netstat -tulnp | grep mysqld
ForMariaDB: sudo netstat -tulnp | grep mariadb
You should see the output something like that i you have installed MariaDB on your VPS:
If on your VPS is enabled UFW firewall, then it will block the MySQL remote access, so you need to add a firewall rule on your firewall to open the port 3306.
sudo ufw allow 3306/tcp
Please keep in mind that enabling remote connections to MySQL server is not a good practice from a security side. So don't expose your database server to outside unless you must, especially in a production environment.