Connect to a MySQL database remotely from a VPS/Dedicated Server

The best advantage of using a cloud server for web hosting is the control it offers. With a VPS or Dedicated Server, you get full control of the system and this means you can easily configure your mysql server to allow remote management. To do this, we follow the steps below:

  1. Log in to the mysql server as root via terminal# mysql -u root -p

    You will be promted for the root user password which you will enter to proceed.

  2. Grant access to the remote user.To do this, you need to first get your IP address. Type the word myip on to get your public IP. Issue the GRANT command to grant remote access to a user:

    mysql> GRANT ALL ON db_name.* TO ‘user’@’remote_ip’ IDENTIFIED BY ‘user_password’;

Note: Include the quotation marks in the SQL command

  1. From there, access the remote computer (the computer you will use to access your database remotely). Access the file and add the following snippet.


$cfg[‘Servers’][$i][‘host’] = ‘XXX.XXX.XXX.XXX’; //provide hostname and port if other than default

$cfg[‘Servers’][$i][‘user’] = ‘db_username’; //user name for your remote server

$cfg[‘Servers’][$i][‘password’] = ‘db_password’; //password

$cfg[‘Servers’][$i][‘auth_type’] = ‘config’; // keep it as config












  1. Launch phpMyAdmin and on the log in page displayed, select a the server whose IP you specified in step 3 above, then type in the log in credentials and log in.


If your phpMyAdmin does not bring a log in page, you can either configure it to load it at startup or log in with your default account and select the server at the top left. See image

Was this article helpful?

Related Articles

Leave A Comment?