Configuring PHPMyAdmin to connect to remote database

0

After Googling the possibility of using PHPMyAdmin to connect to remote databases, I found this article, which confirms that this is supported after a simple config edit.

In the article, the author explains:

The file config.inc.php contains the configuration settings for your phpMyAdmin installation. It uses an array to store sets of config options for every server it can connect to and by default there is only one, your own machine, or localhost. In order to connect to another server, you would have to add another set of config options to the config array. A set of config options would look something similar to this:

$i++;
$cfg['Servers'][$i]['host']          = '';
$cfg['Servers'][$i]['port']          = '';
$cfg['Servers'][$i]['socket']        = '';
$cfg['Servers'][$i]['connect_type']  = 'tcp';
$cfg['Servers'][$i]['extension']     = 'mysql';
$cfg['Servers'][$i]['compress']      = FALSE;
$cfg['Servers'][$i]['auth_type']     = 'config';
$cfg['Servers'][$i]['user']          = 'username';
$cfg['Servers'][$i]['password']      = 'password';

Pay attention that the config array is called cfg and it's a multidimensional array and that all servers, have to be part of the $cfg["Servers"] inner array. The way this works is by using an incrementing variable $i that sets a different inner array for each server inside the $cfg["Servers"] array. For this to work you need to make sure each new set of config options starts with an incremented $i by using $i++.

However, when I browsed for this file in my PHPMyAdmin files, I found its contents to be different than expected:

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Config file view and save screen
 *
 * @package PhpMyAdmin-Setup
 */

if (!defined('PHPMYADMIN')) {
    exit;
}

/**
 * Core libraries.
 */
require_once './libraries/config/FormDisplay.class.php';
require_once './setup/lib/index.lib.php';
require_once './setup/lib/ConfigGenerator.class.php';

$config_readable = false;
$config_writable = false;
$config_exists = false;
check_config_rw($config_readable, $config_writable, $config_exists);
?>
<h2><?php echo __('Configuration file') ?></h2>
<?php PMA_displayFormTop('config.php'); ?>
<input type="hidden" name="eol" value="<?php echo htmlspecialchars(PMA_ifSetOr($_GET['eol'], 'unix')) ?>" />
<?php PMA_displayFieldsetTop('', '', null, array('class' => 'simple')); ?>
<tr>
    <td>
        <textarea cols="50" rows="20" name="textconfig" id="textconfig" spellcheck="false"><?php
            echo htmlspecialchars(ConfigGenerator::getConfigFile())
        ?></textarea>
    </td>
</tr>
<tr>
    <td class="lastrow" style="text-align: left">
        <input type="submit" name="submit_download" value="<?php echo __('Download') ?>" class="green" />
        <input type="submit" name="submit_save" value="<?php echo __('Save') ?>"<?php
if (!$config_writable) {
    echo ' disabled="disabled"';
} ?> />
    </td>
</tr>
<?php
PMA_displayFieldsetBottomSimple();
PMA_displayFormBottom();
?>

Does anyone know where/how, in the more recent versions of PHPMyAdmin, this config data is stored and can be edited?

user317572

Posted 2014-04-26T07:45:09.573

Reputation:

A detail blog: http://goo.gl/FZ6nqD

– Suresh Kamrushi – 2015-10-09T12:30:47.720

Answers

0

You're reading a file in the wrong directory.

The settings are stored in config.inc.php at the root of phpMyAdmin's installation directory; e.g. /usr/share/webapps/phpMyAdmin/config.inc.php. Do not dig deeper than that.

(It's the same place where you can find files config.sample.inc.php, ChangeLog, favicon.ico, and such.)

user1686

Posted 2014-04-26T07:45:09.573

Reputation: 283 655

Yep. Just discovered that, thanks. Tricky duplicate file names... Anyway, I'll accept this when the timer is up! – None – 2014-04-26T07:51:07.577

Looking at this, it's a very weird albeit creative way to build a config. – None – 2014-04-26T07:55:30.460

Once I updated the config, I got the option to connect to the remote database as expected, however, phpMyAdmin seems to be trying to use the password 'YES' rather than the one supplied in the config. Could you have a look at the updated config for my error? https://gist.github.com/jt0dd/11314779

– None – 2014-04-26T08:23:48.870

@jt0dd: The MySQL error messages will never show the actual password. They just tell you whether a password was used for that connection attempt. It's more likely that either the password itself is wrong, or the MySQL account doesn't allow connections from your [i.e. PMA's] address. (All MySQL accounts are in the form of "user"@"source-address", not just "user", so root@localhost can log in only over the Unix socket, and root@10.0.0.2 can log in from IPv4 address 10.0.0.2 and so on.) – user1686 – 2014-04-26T09:51:51.063

Ah, I see. That's my issue. Since 'user' alone is input whe dealing with mysql from the console, I didn't realize that the username takes that format. – None – 2014-04-26T09:54:10.693

@jt0dd: Clients (including phpMyAdmin) always use just the username, yes. The server gets the address directly from the OS after all. And "user"@"address" is just what the server searches for in the user table. My point was, if your account was created as "jt0dd"@"localhost" it won't work over the network. – user1686 – 2014-04-26T10:15:57.583

I see, I see! I just attempted to use 'root@<serverIP>' and was confused when phpMyAdmin tried root@serverIP@myIP - erm. I'm confused now, actually. phpMyAdmin sends root@myip - the remote MySQL server expects root@serverip? I must have that wrong. – None – 2014-04-26T10:17:33.550

Ok, that's confusing. Perhaps I should post a new question for that solution – None – 2014-04-26T10:20:35.750

@jt0dd: PMA sends root. The server translates it to root@clientip (I'm quite sure it's the client address, not the server address), and if it sends an error, you see the translated form in the error message. – user1686 – 2014-04-26T10:22:25.810

0

I've discovered my mistake:

It appears that this isn't an issue of version difference, but of file name duplicates. The file name specified actually exists in 3 or more directories. Make sure you use the one found in the main PHPMyAdmin directory.

user317572

Posted 2014-04-26T07:45:09.573

Reputation: