Connecting to MySQL from External Applications
By default, MySQL databases on your hosting server only accept connections from localhost (the server itself). If you need to connect from an external application, a remote server, or a local development environment, you must enable remote MySQL access for the connecting IP address.
Enabling Remote Access in DirectAdmin
- Log in to DirectAdmin.
- Navigate to Account Manager or find MySQL Management.
- Click on Remote MySQL (or Remote Database Access).
- Enter the IP address of the computer or server that needs to connect.
- Click Add Host or Submit.
To find your current public IP address, visit
https://whatismyip.com from the computer that needs to connect to the database.Connecting from a Remote Application
Use the following connection details in your remote application or database client:
- Hostname: Your server's IP address or hostname (not
localhost). - Port:
3306(default MySQL port). - Database: Your database name (e.g.,
username_dbname). - Username: Your database username (e.g.,
username_dbuser). - Password: Your database user's password.
Connecting via MySQL Workbench
- Open MySQL Workbench and click New Connection.
- Enter a connection name for reference.
- Set the hostname to your server's IP address.
- Enter the port as
3306. - Enter your database username.
- Click Store in Vault to save the password.
- Click Test Connection to verify, then OK to save.
Security Considerations
- Only add IP addresses that genuinely need remote access.
- Remove IP addresses that no longer need access.
- Never use
%(wildcard) to allow access from any IP unless absolutely necessary, as this exposes your database to the entire internet. - Use strong, unique passwords for database users that have remote access.
- Consider using SSH tunneling for a more secure connection method.
If your home or office IP address changes frequently (dynamic IP), you will need to update the remote MySQL access list each time it changes. Consider using a VPN with a static IP for more reliable remote database access.