Access mysql database hosted on remote server using phpMyAdmin
Sat, 9 Jan, 2010
Last week, for one of my projects, I had to access a database which was hosted on remote server and there was no phpMyAdmin installed on that server. As I am an avid user of phpMyAdmin and quite familiar with it, I wanted to access the remote database server using phpMyAdmin only. I knew that phpMyAdmin does give a facility to access database on remote server and it was just a matter of configuration to make it work. When we access http://localhost/phpmyadmin it connects to the local mysql server by default.
To make it connect to other servers you can follow the following steps:
Go to phpMyAdmin directory in your server installation (c:\wamp\phpmyadmin, in my case)
Open config.inc.php file and find
$cfg[‘Servers’] = array();
$i = 1
Below this the configuration of localhost would be provided. All the details of the localhost is given by
$cfg[‘Servers’][$i][‘variable_name’] = ‘value_of_the_variable’;
Many of the variables are defined like that.
Find the value declaration for localhost (mostly the last one would be $cfg['Servers'][$i]['AllowDeny']['rules'] = array();)
Then below this line we need to add the details for the another server we want to connect. We don’t need to repeat all the variables declared for localhost. Only those which are required should be declared for the server we are going to add.
We’ll have to increase the count $i and then give values.
$cfg['Servers'][$i]['host'] = ''; // MySQL hostname or IP address
$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port
$cfg['Servers'][$i]['socket'] = ''; // Path to the socket - leave blank for default socket
$cfg['Servers'][$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')
$cfg['Servers'][$i]['extension'] = 'mysql'; // The php MySQL extension to use ('mysql' or 'mysqli')
$cfg['Servers'][$i]['compress'] = FALSE; // Use compressed protocol for the MySQL connection (requires PHP >= 4.3.0)
$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (valid choices: config, http, signon or cookie)
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed with 'config' auth_type)
Provide appropriate information for the server above.
Now change the value of $cfg['ServerDefault'] to 0. So that when you will open phpmyadmin it will ask you to select the server.
If you will set $cfg['ServerDefault'] = 1; then by default localhost will open.
If you set $cfg['ServerDefault'] = 2; then by default remote database will open.
Did you find this helpful??? No-> Sorry to waste your time and efforts of reading. Yes -> Glad to know that :-)