Opening MySQL Remote Access (2026)
What will you learn in this guide?
In this guide, you will learn how to open your MySQL database securely for remote access.
We will establish a production compatible structure with authorization, firewall and TLS.
Technical Summary
This guide aims to maintain security while removing MySQL's default localhost restriction.
Steps: bind-address → user → UFW → test → SSL/TLS.
Prerequisites
- Ubuntu 20.04 / 22.04 / 24.04
- MySQL 8.0 or above
- sudo authority
- UFW active
- Current database backup
Opening MySQL to Remote Connections
By default MySQL only listens on 127.0.0.1.
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
- This file contains MySQL network settings.
Find the default line:
bind-address = 127.0.0.1
- Recommended (if you are using a private network):
bind-address = 10.0.0.5
- If mandatory (all interfaces):
bind-address = 0.0.0.0
- Apply the changes:
sudo systemctl restart mysql
Note: 0.0.0.0 should only be used with strict firewall and IP restriction.
Creating a Remote MySQL User
- Connect to MySQL with root:
sudo mysql
- Create IP specific user:
CREATE USER 'genixnode_app'@'203.0.113.10' IDENTIFIED BY 'GucluBirSifre123!';
- Define only the necessary permissions:
GRANT SELECT, INSERT, UPDATE, DELETE ON uygulama_db.* TO 'genixnode_app'@'203.0.113.10';
FLUSH PRIVILEGES;
EXIT;
- This structure implements the least privilege principle.
Restricting Access with Firewall (UFW)
- Open port 3306 to trusted IP only:
sudo ufw allow from 203.0.113.10 to any port 3306
Check the rules:
sudo ufw status
- Never use sudo ufw allow 3306.
Testing Remote Connection
- Connect from the application server:
mysql -u genixnode_app -h VERITABANI_IP -p
- If the connection opens, the configuration is correct.
Encrypting Traffic with SSL/TLS (Recommended)
- Force user to TLS:
ALTER USER 'genixnode_app'@'203.0.113.10' REQUIRE SSL;
- Connect via TLS from the client:
mysql --ssl-mode=REQUIRED -u genixnode_app -h VERITABANI_IP -p
- This setting prevents data leaks on the network.
Security Hardening Recommendations
-
Keep root remote access disabled
-
Avoid user@'%' definitions
-
Watch the logs: /var/log/mysql/error.log
-
Change passwords periodically
-
If you have dynamic IP, choose WireGuard VPN
Frequently Asked Questions (FAQ)
1. Is bind-address = 0.0.0.0 safe? By itself, no. IP restriction with firewall is a must.
2. I get the connection refused error. It is usually caused by UFW or bind-address.
3. Can I connect remotely with root? Not recommended. The security risk is very high.
4. My IP address is constantly changing. Use a VPN. % definition is major security vulnerability.
Result
MySQL remote access is secure and scalable when configured correctly. Bind-address, user rights and firewall should be used together.
You can easily install this structure on GenixNode VDS for a high-performance and secure database infrastructure.

