Remote MySQL in cPanel: Allowing External Access to Databases
By default, MySQL and MariaDB databases in cPanel are configured for local connections only due to security reasons—for example, from your website hosted on the same server via localhost. With the Remote MySQL feature, you can allow selected external hosts to access your databases.
This is particularly useful if you work with a local database management tool like MySQL Workbench, connect an external application, or want to grand a development server access to a specific database.
%, as these allow access from any source globally.When Do You Need Remote MySQL?
Remote MySQL is required when a database connection does not originate directly from your website on the hosting server, but is instead established by an external system.
- Local Development: Accessing your database from your computer using MySQL Workbench, TablePlus, DBeaver, or a similar database tool.
- External Application: Connecting from software or a server located outside of your web hosting environment.
- Development Server: Accessing a database within your hosting account from a staging or testing environment.
- Analysis or Maintenance: Temporary access for database analysis, migration, or troubleshooting.
Whitelisting an External Host for Remote MySQL
To allow an external device or server to access your database, you must whitelist its public IP address in cPanel.
- Log in to cPanel.
- In the Databases section, open the Remote MySQL feature.
- Determine the public IP address of the device or server that needs access.
- Enter this IP address in the Host field.
- Optionally, add a comment, such as Office PC, Dev Server, or MySQL Workbench.
- Click Add Host.
Once added, the whitelisted host can establish a connection to the MySQL or MariaDB server, provided that the username, password, database name, and server address are also correct.
What Connection Details Do You Need?
To establish an external database connection, you will generally need the following details in your database tool or external application:
| Detail | Description | Example |
|---|---|---|
| Server / Host | Hostname or IP address of the database server | yourdomain.ch or server address |
| Port | Standard port for MySQL connections | 3306 |
| Database Name | Full database name including the cPanel prefix | user_database |
| Username | Full database user including the cPanel prefix | user_dbuser |
| Password | The password set for the database user | Your chosen database password |
user_database instead of just database.Managing or Removing Access Hosts
In the Remote MySQL section, you will see a list of currently authorized hosts. Review this list regularly and remove any entries that are no longer needed.
- Use Comments: Clearly describe each entry so you can easily identify why the access was granted later on.
- Revoke Access: Remove hosts that are no longer required using the delete function.
- Temporary Access: If access was only granted for a migration or maintenance task, it should be removed immediately afterwards.
Wildcards in Remote MySQL
Depending on the configuration, cPanel supports wildcards for host access. This allows you to whitelist entire IP ranges. For instance, an entry like 1.2.3.% covers all IP addresses within that specific block.
Troubleshooting Common Remote MySQL Connection Issues
If the connection fails despite whitelisting the host, please verify the following points:
| Issue | Possible Cause | Solution |
|---|---|---|
| Connection refused | The external IP address is not or no longer whitelisted. | Check your current public IP address and add it to Remote MySQL. |
| Timeout | A firewall, router, or local network is blocking the connection. | Check if outgoing connections on port 3306 are permitted. |
| Access denied | Username, password, or user privileges are incorrect. | Verify the database user, password, and user rights inside cPanel. |
| Unknown database | The database name is incorrect or incomplete. | Use the full database name including the cPanel prefix. |
| Incorrect hostname | localhost is being used, even though the connection is external. |
Use the external server name or the appropriate server address. |
Remote MySQL and User Privileges
Whitelisting a host via Remote MySQL does not replace database user privileges. An external host can only successfully access a database if a database user has been explicitly created and assigned to that specific database.
Therefore, if you experience connection problems, also check the MySQL Databases section in cPanel:
- Does the database user exist?
- Is the user assigned to the correct database?
- Does the user have all required privileges?
- Was the password entered correctly in the external application?
Security Best Practices for Remote MySQL
- Only authorize specific IP addresses, avoiding unnecessarily large ranges.
- Remove temporary access rules immediately after completing your work.
- Use strong, unique passwords for all database users.
- Create separate database users for different applications whenever possible.
- Grant only the exact privileges that are actually required.
- Never store database credentials unencrypted in publicly accessible files.
Summary
With Remote MySQL, you allow selected external devices or servers to access your MySQL or MariaDB databases. This feature is highly practical for development, maintenance, and external applications, but should be used with caution.
For a successful connection, you need both the host authorization and correct access details, an assigned database user, and matching privileges.
Are you trying to access your database externally but keeping getting connection errors?
The CURIAWEB Technical Team is happy to assist you in checking Remote MySQL settings, user privileges, and connection details.