When I attempt to load phpMyAdmin 4.8.0 using AuthType=config I get an error:
Cannot connect: invalid settings.
mysqli_real_connect(): (HY000/2002): No such file or directory
phpMyAdmin tried to connect to the MySQL server, and the server rejected the
connection. You should check the host, username and password in your
configuration and make sure that they correspond to the information given by
the administrator of the MySQL server.
The phpMyAdmin config.inc.cfg contains:
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'MYUSER';
$cfg['Servers'][$i]['password'] = 'MYPASSWORD';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['socket'] = '/tmp/mysql57.sock';
I can connect to mysql via commandline using socket with same credentials and /tmp/mysql57.sock exists
Also:
ps -edf | grep mysql
mysql 18090 17814 0 20:17 ? 00:00:00 /usr/local/mysql57/bin/mysqld –defaults-file=/usr/local/mysql57/my.cnf –basedir=/usr/local/mysql57 –datadir= mysqldata/mysql57 –plugin-dir=/usr/local/mysql57/lib/plugin –log-error=myhost.com.err –pid-file=myhost.com.pid –socket=/tmp/mysql57.sock –port=3306
I have skip-networking in my.cnf so cannot use 127.0.0.1 for host. What can be the problem?
More Details:
Centos 7.4
mysql-5.7.21-linux-glibc2.12-x86_64 (generic binary), community version
PHP 7.2.4
nginx-1.12.2
Best Answer
My guess is that the
PrivateTmp
directive is set toyes
in the service responsible for PHP runtime, thus defining a separate/tmp
directory and preventing PHP from connecting to/tmp/mysql57.sock
socket located in system's temporary directory.There are two possible solutions, which should be applied by extending either
nginx.service
orphp-fpm.service
unit. It depends on how nginx is configured to run PHP scripts.Option 1: figure out what systemd unit should be extended and set
PrivateTmp=no
there.Option 2: configure MySQL to listen to a UNIX socket in another directory located outside
/tmp
and/var/tmp
. I suggest you to use either/run/mysqld.socket
or/run/mysqld/mysqld.socket
for that.Reference from systemd.exec(5) manual page: