phpMyAdmin is throwing a #2002 cannot log in to the mysql server phpmyadmin

前端 未结 27 2367
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 14:50

I have installed MySQL server enterprise 5.1 on my local machine and now I want to install phpMyAdmin, but it does not work.

I have unrared phpMyAdmin to my server r

27条回答
  •  感动是毒
    2020-11-27 15:20

    Had this problem a number of times on our setup, so I've made a check list.

    This assumes you want phpMyAdmin connecting locally to MySQL using a UNIX socket rather than TCP/IP.

    UNIX sockets should be slightly faster as they have less overhead and can be more secure as they can only be accessed locally.

    Service

    • Is the mysqld service running? service mysqld status
    • .. If not service mysqld start
    • Has config has changed since service started? service mysqld restart

    MySQL Config (my.cnf)

    • Check that there isn't a non-socket client protocol set, e.g. protocol=tcp
    • Check that the socket location is accessible and has the right permissions

    PHP Config (php.ini)

    If you can connect locally from the command line, but not from phpMyAdmin, and the socket file is not in the default location:

    • Set the mysqli default sockets to the new location: mysqli.default_socket = *location*
    • ... I also set the pdo_myql.default_socket and mysql.default_socket just to be sure
    • Restart your web service (httpd in my case) service httpd restart

    phpMyAdmin Config (config.inc.php)

    • Check that the host is set to localhost: $cfg['Servers'][$i]['host'] = 'localhost';
    • The socket location can also be set here: $cfg['Servers'][$i]['socket'] = '*location*';

    N.B.

    As pointed out by @chk; Setting the $cfg['Servers'][$i]['host'] from localhost to 127.0.0.1 just causes the connection to use TCP/IP rather than using the socket and is more of a workaround than a solution.

    The MySQL config setting bind-address= also only affects TCP/IP connections.

    If you don't need remote connections, it is recommended to turn off TCP/IP listening with skip-networking.

提交回复
热议问题