Answer a question

Setup:

  • Debian Jessie
  • mysqld 5.5.46-0+deb8u1
  • nginx 1.8.0 from dotdeb.org
  • php-fpm 7.0.0 RC7 from dotdeb.org
  • phpMyAdmin 4.5.2

I recently upgraded to PHP 7.0 RC7 on my development linux box.

Since then, phpMyAdmin is only throwing "Cannot log in to the MySQL server" as well as "Connection for controluser as defined in your configuration failed." without further message, error number or details.

I was not able yet to trace any more information out of this WHY the connection fails (the highly abstracted classes from phpMyAdmin makes it hard).

Any hint on how to get more information out of phpMyAdmin is much appreciated.

  • The MySQL server is running
  • I can login on the terminal with the mysql and mysqladmin command
  • I tried to reset and refresh the MySQL passwords
  • My GOGS instance can access it
  • A quick self made php script can use it as well (using mysqli).
  • I tried socket-based as well as tcp-based access in phpMyAdmin
  • I tried config-based and http-based authentication with same result

Relevant configuration below:

$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '/var/run/mysqld/mysqld.sock';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['ssl'] = true;

And here is my test script which works fine:

<?php
$_dbHost = 'localhost';
$_dbUser = 'root';
$_dbPass = 'mysupersecretrootpassword';
$_dbName = '';
$_dbPort = 0;
$_dbSock = '/var/run/mysqld/mysqld.sock';

$mysqli = new mysqli($_dbHost, $_dbUser, $_dbPass, $_dbName, $_dbPort, $_dbSock);

if ($mysqli->connect_errno) {
    echo "Error: Failed to make a MySQL connection, here is why: \n";
    echo "Errno: " . $mysqli->connect_errno . "\n";
    echo "Error: " . $mysqli->connect_error . "\n";
    exit;
} else {
    echo "Connection Successfull";

    $dbList = $mysqli->query('show databases;');
    echo "<pre>";
    var_dump($dbList->fetch_assoc());
    echo "</pre>";
}
?>

Answers

Setup:

  • Debian 8.2 (Jessie)
  • PHP version: 7.0.0-4 | from Sid
  • lighttpd/1.4.35 (ssl)
  • 10.0.19-MariaDB-log | mysqlnd 5.0.12-dev - 20150407

Tested with phpMyAdmin versions 4.4.7, 4.5.2 & 4.6.0-dev using a socket connection.

Encountered the same problem as you and traced it to the secure connection to the MySQL-Server.

Temporary fix:

In your config.inc.php (phpMyAdmin) comment

$cfg['Servers'][$i]['ssl'] = true;

which determines if ssl would be used for the connection between phpMyAdmin and the MySQL-Server.

On the side:

The patch Marc Delisle wrote will most likely throw an error in that state, correct would be:

    error_log(var_export($this->_extension->getError(null), true));

your web server will then log something like this:

    (mod_fastcgi.c.2695) FastCGI-stderr: PHP message: '#2006 - MySQL server has gone away'

which is more like a false positive in this case

Update 1:

There seems to be a problem with the MYSQLI_CLIENT_SSL constant which sets $client_flags in /libraries/dbi/DBIMysqli.class.php at row 176. As soon as these get set, the connection will be dropped.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐