> ## Documentation Index
> Fetch the complete documentation index at: https://kb.stablepoint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to use a remote MySQL database with cPanel

By default, applications hosted with us connect to MySQL on the same server using localhost. But sometimes you need the reverse — an application running elsewhere (your local machine, another server, a reporting tool) connecting to a database hosted on your cPanel account. That's remote MySQL.

## Step 1: Allow the remote host in cPanel

1. Log in to cPanel.
2. In the **Databases** section, click **Remote MySQL**.

![image](https://files.readme.io/1571b5f-remote_mysql.png)

3. In the **Add Access Host** field, enter the IP address of the machine that will connect.
   * You can use the % wildcard (for example, 203.0.113.%) to allow a range.
   * To find your current IP, visit [http://ipfinder.us](http://ipfinder.us).
4. Click **Add Host**.

<Warning>
  Avoid adding % (all hosts) on its own. That allows connection attempts from anywhere on the internet, and your database security then rests entirely on the password.
</Warning>

## Step 2: Connect from the remote application

Use these connection details:

| Setting  | Value                                                     |
| :------- | :-------------------------------------------------------- |
| Host     | Your domain name or server IP address                     |
| Port     | 3306                                                      |
| Database | Your full database name (including the cPanel prefix)     |
| Username | Your full database username (including the cPanel prefix) |
| Password | The database user's password                              |

Example from the MySQL command line:

```shell theme={null}
mysql -h yourdomain.com -P 3306 -u cpuser_dbuser -p cpuser_dbname
```

Example from PHP:

```php theme={null}
<?php
$mysqli = new mysqli('yourdomain.com', 'cpuser_dbuser', 'password', 'cpuser_dbname', 3306);
```

## Troubleshooting

* **Connection refused / timeout:** the remote host's IP isn't in the allowed list, or a firewall between you and the server blocks port 3306. Double-check the IP you added — if you're on a dynamic connection, your IP may have changed.
* **Access denied:** the username/password is wrong, or the database user isn't assigned to the database in cPanel (**MySQL Databases** → **Add User To Database**).
* **Works locally but not remotely:** make sure you're using the full prefixed username (cpuser\_dbuser), not just dbuser.

<Note>
  For security and latency reasons, keep the application and database on the same server where possible. Use remote MySQL for management tools, reporting, and integrations rather than as the primary application connection.
</Note>
