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

前端 未结 27 1888
爱一瞬间的悲伤
爱一瞬间的悲伤 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:18

    Right-click My Computer -> Manage -> Services Choose "Services" under the "Services and Application" from right pane Then search for the "mysql" Service. When you find it, double click to start that service.

    Now you should be able to run and login to PhpMyAdmin

    0 讨论(0)
  • 2020-11-27 15:19

    This is old but as it is the first result in Google,

    Please note that this also happens when your MySql service is down,

    I fixed this by simply restarting MySQL Server using:

    /etc/init.d/mysql restart

    in SSH (Command is for a CentOS/CPanel server)

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-11-27 15:22

    Check whether you server is running or not.

    0 讨论(0)
  • 2020-11-27 15:23

    In ubuntu OS in '/etc/php5/apache2/php.ini' file do configurations that this page said.

    0 讨论(0)
  • 2020-11-27 15:24

    If you're getting the #2002 Cannot log in to the MySQL server error while logging in to phpmyadmin, try editing phpmyadmin/config.inc.php and change:

    $cfg['Servers'][$i]['host'] = 'localhost';

    to:

    $cfg['Servers'][$i]['host'] = '127.0.0.1';

    Solution from Ryan's blog

    Edit (20-Mar-2015):

    Note that if you're on a fresh install, config.inc.php may not exist. You need to rename / copy config.sample.inc.php and then change the relevant line

    0 讨论(0)
提交回复
热议问题