Can't start phpMyAdmin. Keep getting the #2002 socket error

前端 未结 9 1916
难免孤独
难免孤独 2020-12-31 05:44

I\'ve been trying to set mysql and phpMyAdmin for the last 12 hours, without any success. And yes, after hours and hours of Google-ing I know that is a common problem and I\

9条回答
  •  醉话见心
    2020-12-31 05:52

    Since you did not mention MAMP, I am assuming you are not using it so this is for a manual install but it will likely also work for MAMP.

    In my experience, this is caused by the socket variable of your mysql. By default, MySQL uses /tmp/mysql.sock.

    You can get the MySQL socket variable by logging into your MySQL and doing

    show variables like '%socket%'
    

    that will show you the location of the socket file.

    Now, create a php phpinfo() file and look for mysql.default_socket under the mysql or mysqli section. Mine was /var/mysql/mysql.sock. This shows that PHP is looking for the file in a different location than mysql is using.

    Assuming you have same values, open new terminal and enter

    cd /var
    mkdir mysql
    cd mysql
    ln -s /tmp/mysql.sock mysql.sock
    

    this will create a link to the mysql socket file inside the location PHP is checking from.

    PHPMyAdmin should work now.

提交回复
热议问题