How to Remote Connect to a MySQL Database
Step 1: Authorize Your IP Address
Before your software can connect to the server, your computer must be recognized as a trusted source.
- Find your public IP: Search "What is my IP" on Google and copy the numeric address (e.g., 1.2.3.4).
- Log in to cPanel: Navigate to the Databases section and click Remote MySQL®.
- Add Access Host: Paste your IP address into the Host field.
- Optional: Add a comment like "Home Office" to remember this IP.
- Click Add Host: You should see a success message confirming the IP is authorized.
Step 2: External Connection Settings
Use your database client (e.g., MySQL Workbench, DBeaver) with the following details:
- Hostname/Server: Your domain name (e.g., yourdomain.com) or server IP.
- Port: 3306 (standard MySQL port).
- Username: Full database username (e.g., user_dbadmin).
- Password: The password set when creating the database user.
- Database: Optional — specify a database (e.g., user_store).
Step 3: Troubleshooting Common Issues
- Connection Timed Out: Usually caused by a firewall or ISP blocking Port 3306. Ensure outgoing traffic is allowed.
- "Access Denied" Error:
- Check Username: Must include full prefix (e.g., user_dbadmin).
- Check IP: If your ISP uses dynamic IPs, update your authorized IP in Remote MySQL if it changes.
- Using a Wildcard (%):
- Allows any IP to attempt login. ⚠ Security Risk: This increases the risk of brute force attacks. Use your specific IP whenever possible.
???? Pro Tip: Use SSH Tunneling for maximum security. Many database clients (DBeaver, Sequel Ace) support it. This tunnels traffic securely and removes the need to open Port 3306 or authorize your IP.