Setting up Remote MySQL in cPanel

Today my client was facing problem to setup a remote mysql connection. He wanted to connect a database which belongs to another server and domain. Its fairly simple. But most of the tasks remains on the remote server.

Suppose, your remote domain/server is and your scripts are running in I assume that you already have a database in the We just need to access it from remote server. Also assuming that your database name is remoteco_main. Note, all databases & also usernames (for database connection) in cPanel are prefixed by your username of cPanel and _ (underscore). So remoteco in remoteco_main is the username of cPanel. So you have a complete database, username & password setup which works on

  • Login to cPanel of
  • Click Manage Remote MySQL Access
  • Enter the IP Address of in the box “Host (% wildcard is allowed):“. It’s the IP address where your is hosted. Usually it is the server shared IP unless you have a dedicated IP address. You can also enter the domain name as Host.
  • Click Add Hosts
  • Now open your database configuration file in In normal cases,the host was localhost.That is you may get the code as $dbhost=’localhost’ or $db_host=’localhost’.
  • Now you need to replace the term localhost with actual domain or IP address. You enter or the IP of as host in the database configuration file.

An Example:


$dbhost=’′; //ip of the you can also put here.

$dbname = ‘remoteco_db’; //database name

$dbuser= ‘remoteco_main’; //user name to access database

$dbpass = ‘123456’; //password of the database


Thats it, you should now be able to connect to your remote mysql server.