Skip to content

Knowledge base

Search every guide

Allowing remote access to MySQL safely

Connect to your server's database from another machine.

The safest way is an SSH tunnel, which doesn't open the database to the internet:

ssh -L 3307:127.0.0.1:3306 root@203.0.113.10
# then connect your tool to 127.0.0.1:3307

If you must open MySQL directly:

  1. Set bind-address = 0.0.0.0 in the MySQL/MariaDB config and restart it.
  2. Create a user allowed only from your IP: CREATE USER 'app'@'198.51.100.7' IDENTIFIED BY '…';
  3. In IDX Panel's firewall, allow port 3306 only from that IP.

Never open port 3306 to everyone. Database ports are a top target for attacks.

On cPanel hosting, use Remote MySQL in cPanel to allow your IP address.