By default, your MySQL database only accepts connections from scripts running on your own hosting account. If you need an external application, a desktop tool, or a separate server to connect directly to the database, you have to explicitly authorize that connection by adding its IP address as a remote access host. Here's how to do it in both control panels.
What You'll Need First
- The exact IP address of the server, application, or device that will be connecting. If you're not sure what it is, the application itself, or a quick search for "what is my IP" from that machine, will usually show it.
- The name of the database you want to open up, and a database user that already has privileges on it.
Only add the specific IP addresses you actually need. Using a wildcard to allow connections from anywhere exposes your database to the internet and is a common way accounts get compromised. Avoid it unless you have no other option, and if you must use it, remove it again once you're done testing.
Adding a Remote Access Host
In cPanel
- Log in to your cPanel account.
- Under the Databases section, click Remote MySQL.
- In the Add Access Host field, type the IP address that needs to connect.
- Optionally add a note in the Comment field so you remember what the entry is for later.
- Click Add Host.
The address now appears in the Manage Access Hosts list below. Repeat the steps for any additional IP addresses that need access.
In DirectAdmin
- Log in to your DirectAdmin account.
- Open MySQL Management.
- Click on the name of the database you want to open remote access for.
- Find the Access Hosts section and click Add Access Host.
- Enter the specific IP address that needs to connect and save your change.
The new host now shows in that database's access list. Repeat for any other addresses you need to authorize.
Testing the Connection
Once the host is added, connect using your usual MySQL client with your hosting server's hostname or IP address, the database name, and the database user's credentials. Changes to remote access hosts normally take effect immediately, so you shouldn't need to wait to test.
If the connection still fails, double check that the IP address was entered correctly (a typo is the most common cause), and confirm the database user has the correct privileges on that specific database.
If you haven't set up the database or database user yet, see How to Create a MySQL Database and Database User. You can find your account's hostname and IP address in How to Find Your Hosting Server's IP Address and Hostname.