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.
$i++;
$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 :-)
Comments
hi mittal patel!! I really
hi mittal patel!!
I really want to say many thanks to u......... this is really a grate help
for me...... i think i can use same approach in Linux too...
Some things i want to know regarding
1. changing port of my existing mysql....,
2.I want to configure the existing mysql with phpmyadmin...
Thanks & Regrads,
Yash
Nice
Thanks! it worked :D
Nice Help
Really its gr8.....
while i am searching arround web , googling but did not found the exact solutions..
This really works
Thanks A lot :)
working perfect
Thank you very much
Thanks
Thanks for the appreciation Himal...
Thanks!
Nice quick easy to understand article. My friend sent me this link and I am logged in to a server I have been trying to access all day now.
Works
Works Perfect!!!! I have been searching for an hour for a way to do this. Thank you so much!
Great
Oh thanks so much
Thanks
Very rare to have such a clear instruction. So much information on the web is confusing and does not work. This is great!
You're welcome
Glad to know it helped you Betts... :-)
Cool
Clear and concise article. Very useful.
Really Very Help Full seems like manual
This post is Really Very Help Full seems like manual as i forgot same thing that i did in past by using same post. This time it helps me lot as i have already wasted my sometime with googling but i have this in mind that i have seen some good help regarding this in past. Finally i found that.
Thanks
Many, many thanks for this post!!!
I also like phpmyadmin very much and have a problem like this.
Your post is really! useful and I hope it will work on my pc.
It's just a small setting in the config file, but when you google this and find this post, it's really amazing. Looking forward to finding more useful posts ;-)
Hi
Hi Mittal,
I'm somehow unable to make it work, will you be able to help me with it.
I have 2 servers App Server on which I have PHPMyadmin & DB on which I have My sql. I also Have MySql installed on my machine. Somehow even after adding the information for both MuSql i'm unable to connect. It always asks for credentials and accepts my local machine details.
It'll be great if you can help.
here is the code...
/* $Id: config.sample.inc.php 9675 2006-11-03 09:06:06Z nijel $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**.
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use scripts/setup.php
*
* All directives are explained in Documentation.html and on phpMyAdmin
* wiki
*/
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/*
* Servers configuration
*/
$i = 0;
$cfg['ServerDefault'] = 0;
/*
* First server
*/
$i++;
$cfg['Servers'][$i]['host'] = 'IP here';
$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';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password1';
/*
* Second server
*/
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$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';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password2';
/*
* End of servers configuration
*/
/*
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>
Thanks
Hey guy, thank you soo much. this post was very helpfull to me!!
using phpmyadmin to look a remote server
Thanks very much, it worked
Glad it worked for you
Hey Daniela,
I am happy that it worked for you and it could help you. :-)
I need the prosedure to input
I need the prosedure to input the remote IP/host manualy in the phpmyadmin login form. How to do that?
Please provide more detail
Hello there,
Can you please provide more detail about what you want to do exactly? This isn't sufficient information to bring you help.
Nice Worc! Thank you
Nice Worc! Thank you
thanks alot
thanks alot
great man
worked great
2 years later and you are
2 years later and you are still helping people... :) Thanks!
Add new comment