Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

前端 未结 30 1262
南方客
南方客 2020-11-22 11:30

I am getting the following error when I try to connect to mysql:

Can\'t connect to local MySQL server through socket \'/var/lib/mysql/mysql.sock\' (2)<

30条回答
  •  孤街浪徒
    2020-11-22 11:51

    If your file my.cnf (usually in the etc folder) is correctly configured with

    socket=/var/lib/mysql/mysql.sock
    

    you can check if mysql is running with the following command:

    mysqladmin -u root -p status
    

    try changing your permission to mysql folder. If you are working locally, you can try:

    sudo chmod -R 777 /var/lib/mysql/
    

    that solved it for me

提交回复
热议问题