Docs / Databases / How to Enable Remote MySQL Access

How to Enable Remote MySQL Access

By Admin · Feb 25, 2026 · Updated Apr 24, 2026 · 338 views · 1 min read

By default, MySQL only accepts connections from localhost. Here's how to enable remote access securely.

1. Configure MySQL

Edit /etc/mysql/mysql.conf.d/mysqld.cnf:

bind-address = 0.0.0.0

2. Create Remote User

CREATE USER 'remoteuser'@'%' IDENTIFIED BY 'StrongPassword!';\nGRANT ALL PRIVILEGES ON myapp.* TO 'remoteuser'@'%';\nFLUSH PRIVILEGES;

For better security, replace % with a specific IP:

CREATE USER 'remoteuser'@'203.0.113.50' IDENTIFIED BY 'StrongPassword!';

3. Open Firewall

ufw allow from 203.0.113.50 to any port 3306

4. Restart

systemctl restart mysql

Security Warning

Never expose MySQL to the entire internet. Only allow specific IPs that need access.

Was this article helpful?