3

I have a LAMP stack box (CentOS 6) and another CentOS 6 box running mysql server.

I've installed phpmyadmin on the LAMP box but I can not get it to talk to my SQL box at all.

I have configured the following in config.inc.php

/* Servers configuration */
$i = 0;

/* Server: usp-ggdb2 [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'usp-ggdb2';
$cfg['Servers'][$i]['host'] = '10.1.2.3';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';

When I browse to the phpmyadmin site I get the following error:

#2002 - Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) The server is not responding (or the local server's socket is not correctly configured).

I don't know why it is talking about trying to connect to a local server as I've configured just the one server (and it's remote).

If i tcpdump I can see that it makes no attempt to establish a connection to the IP i specified.

It's as if my config file is being ignored.

Is there a way to turn on some more debug information? Any and all suggestions welcome!

1

3 Answers 3

3

I have resolved the issue. Indeed, my config file was being ignored. I had been copying config.inc.sample.php to config.inc.php in the top level directory of the website (/var/www/html/pma).

However, on CentOS 6 there is a separate config directory -- /etc/phpMyAdmin/. Once I copied my config there, everything works ok.

2

One of the standard settings found in RHEL 6 and CentOS 6 is SELinux defaults to enforcing mode. You can verify that with the getenforce command.

If in Enforcing mode the quickest way to verify if that SELinux is the culprit is often to temporarily disable SELinux with setenforce 0. If with SELinux disabled everything works as expected it's confirmed.

Return SELinux to enforcing mode with setenforce 1 and set the policy governing network based database access for web applications to allowed:

   setsebool -P httpd_can_network_connect_db 1

If the MySQL database is listening to a non-standard port that may be insufficient and you could try to allow the generic network policy:

  sesebool -P httpd_can_network_connect 1 
1
  • SELinux is disabled on both machines. I've created a simple test PHP page with a mysqli_connect statement and this works fine. It's as if my config file is being completely ignored.
    – wimnat
    May 4, 2014 at 23:42
1

I ran into another reason you can get this error. You need to meet the following conditions

  1. Use the MySQL Native Driver for PHP (which is recommended)
  2. Use MySQL 5.6 or later
  3. Use a self-signed SSL certificate for MySQL communication

As described in this PHP bug, MySQLND will obey the preferences of MySQL and try to validate the SSL certificate. Since it can't (being self-signed) the connection simply fails with a 2002 error (nice and vague!)

As noted in the bug, PHP 5.6.16 (also present in 7.0+) added another connection option to mysqli_real_connect called MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT, which disables the validation of the SSL certificates on the MySQLND side. For versions prior to PMA 4.6.0 you will have to edit libraries/dbi/DBIMysqli.php and edit the line with

$client_flags |= MYSQLI_CLIENT_SSL;

And replace it with (ONLY FOR PHP 5.6.16 or later)

$client_flags |= MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;

For PMA 4.6.0 or later you can simply set in the config

$cfg['Servers'][$i]['ssl_verify'] = false;
1
  • Note: you can add if ($cfg['Server']['ssl_verify'] === false) { $client_flags |= MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT; } So the old PMA is compatible with PMA6+ (you can use the same config file)
    – hilnius
    Sep 19, 2018 at 7:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .