Configure a Remote MySQL Database in cPanel
In cPanel it’s possible to host your website on one server and your MYSQL database on another. This is called a Remote MYSQL Database cPanel. Whilst most users will never need to use this feature it is handy to mitigate certain risks. Users who are Resellers or Web Hosting customers will need to contact the support team to allow Remote MYSQL Connections.
It’s worth pointing out if you are setting up a remote MYSQL Database the remote database server should fast. We recommend an NVMe VPS. These are faster than an SSD server. It should also not be too far away from your production server. Try to get a server in the same DC or at least the same country.

Setup Remote MySQL Database
To set up Remote MYSQL Database on your website server, access WHM and in the search bar type “SQL”. Click the “Additional MySQL Access Hosts link. In the Additional MySQL Access Hosts box place the IP of the remote MYSQL server. If this is a cPanel server then your MySQL database server shares the same IP as your server. Click save once done.

Next, in your firewall configuration, you need to open port 3306 to allow your server to communicate with the remote MySQL server. If you are using CSF you can click “Firewall Configuration” and add the port to the IPv4 port settings.
Now on your Remote MySQL server repeat the above steps but place your websites servers IP in the Additional MySQL Access Hosts host. So, in your production server you will have your MySQL servers IP and in your MySQL server, you will have your website servers IP. If you are using any dedicated IPs you should also place them in these boxes. Click Save.
On your MySQL server ensure port 3306 is open.
Finally, in cPanel on your Remote MySQL server login and click the Remote MySQL icon and place your website in http://www.domain.com format. This will allow connections from your website to your MySQL Database.

Repeat the above step on your website server but this time ensure your MySQL IP is listed and any website you are using.
Add Database To Software Install
You can now place your remote database username and password in any configuration files you have. Remember to remove any reference to “localhost” which is the local MySQL server and place your remote MySQL servers IP in this field. For example, if our remote MySQL serves IP was 192.168.0.100 your WordPress configuration file would look like this;
define( 'DB_NAME', 'database_name_here' );
define( 'DB_USER', 'username_here' );
define( 'DB_PASSWORD', 'password_here' );
define( 'DB_HOST', '192.168.0.100' );
When you visit your website via http you should not see your website running off your website server but the database is being loaded from the remote server. If you see any “Error Connecting To Database” issues you need to double check your setup. Ensure your firewall is not blocking the connection.
How was this article? – Configure a Remote MySQL Database cPanel
More from cPanel
How To Install A Cloudflare Origin SSL Certificate In cPanel
Free SSL Certificates from places like cPanel or Let's Encrypt are great. When Let's Encrypt first introduces free SSL Certificates …
Create a SWAP partition on CentOS, RHEL and AlmaLinux without a reboot
SWAP is a memory type that Linux NVMe VPS Servers use to process requests. Memory will be held in SWAP …
Help fixing Error: last request failed: [AUTH] Authentication failed.
The Error: last request failed: [AUTH] Authentication failed error can be caused by a range of things. It could be …