I have phpMyAdmin installed on my local machine. How can I make it connect to an external server?

- 37,464
- 17
- 118
- 167

- 2,165
- 3
- 20
- 22
-
Does this answer your question? [Using PHPMyAdmin to administer Amazon RDS](https://stackoverflow.com/questions/4402482/using-phpmyadmin-to-administer-amazon-rds) – Nguyen Tan Dat Jan 06 '23 at 06:33
6 Answers
In the config file, change the "host" variable to point to the external server. The config file is called config.inc.php
and it will be in the main phpMyAdmin folder. There should be a line like this:
$cfg['Servers'][$i]['host'] = 'localhost';
Just change localhost
to your server's IP address.
Note: you may have to configure the external server to allow remote connections, but I've done this several times on shared hosting so it should be fine.

- 70,219
- 68
- 205
- 290
-
-
1It's the file called `config.inc.php` in the phpMyAdmin folder. – DisgruntledGoat Nov 12 '09 at 13:13
-
i did the previous solution but it asked me for the password and it doesn't logged i don't know what is the problem ?? – Neveen Nov 12 '09 at 13:54
-
It's difficult to say. Are you sure you're using the correct username and password for the external server? – DisgruntledGoat Nov 12 '09 at 18:15
To set up an external DB and still use your local DB, you need to edit the config.inc.php file:
On Ubuntu: sudo gedit /etc/phpmyadmin/config.inc.php
The file is roughly set up like this:
if (!empty($dbname)) {
//Your local db setup
$i++;
}
What you need to do is duplicate the "your local db setup" by copying and pasting it outside of the IF
statement I've shown in the code below, and change the host to you external IP. Mine for example is:
$cfg['Servers'][$i]['host'] = '10.10.1.90:23306';
You can leave the defaults (unless you know you need to change them)
Save and refresh your PHPMYADMIN login page and a new dropdown should appear. You should be good to go.
EDIT: if you want to give the server a name to select at login page, rather than having just the IP address to select, add this to the server setup:
$cfg['Servers'][$i]['verbose'] = 'Name to show when selecting your server';
It's good if you have multiple server configs.

- 9,349
- 5
- 58
- 73
-
-
@Tanner, that happens in the `/etc/phpmyadmin/config.inc.php` file (the host). – Jarrod Aug 27 '19 at 23:59
using PhpMyAdmin version 4.5.4.1deb2ubuntu2, you can set the variables in /etc/phpmyadmin/config-db.php
so set $dbserver
to your server name, e.g. $dbserver='mysql.example.com';
<?php
##
## database access settings in php format
## automatically generated from /etc/dbconfig-common/phpmyadmin.conf
## by /usr/sbin/dbconfig-generate-include
##
## by default this file is managed via ucf, so you shouldn't have to
## worry about manual changes being silently discarded. *however*,
## you'll probably also want to edit the configuration file mentioned
## above too.
##
$dbuser='phpmyadmin';
$dbpass='P@55w0rd';
$basepath='';
$dbname='phpmyadmin';
$dbserver='localhost';
$dbport='';
$dbtype='mysql';

- 37,464
- 17
- 118
- 167
at version 4.0 or above, we need to create one 'config.inc.php' or rename the 'config.sample.inc.php' to 'config.inc.php';
In my case, I also work with one mysql server for each environment (dev and production):
/* others code*/
$whoIam = gethostname();
switch($whoIam) {
case 'devHost':
$cfg['Servers'][$i]['host'] = 'localhost';
break;
case 'MasterServer':
$cfg['Servers'][$i]['host'] = 'masterMysqlServer';
break;
} /* others code*/

- 83,997
- 17
- 205
- 265

- 689
- 10
- 13
-
-
yeah... rename file config.sample.inc.php to config.inc.php then change : $cfg['Servers'][$i]['host'] = 'localhost'; to your remote mysql server address. for example mysql is on this ip.. $cfg['Servers'][$i]['host'] = '192.168.1.200:3306'; – Mang Jojot Mar 15 '18 at 03:17
You can use the phpmyadmin setup page (./phpmyadmin/setup) to generate a new config file (config.inc.php
) for you. This file is found at the root of the phpMyAdmin directory.
Just create the config folder as prompted in setup page, add your servers, then click the 'Save' button. This will create a new config file in the config folder you just created.
You now have only to move the config.inc.php
file to the main phpMyAdmin folder, or just copy the lines concerning the servers if you got some old configuration done already you'd like to keep.
Don't forget to delete the config folder afterwards.

- 1
- 2
in the config.inc.php, remove all lines with "$cfg['Servers']" , and keep ONLY the "$cfg['Servers'][$i]['host']"

- 1,716
- 3
- 24
- 42