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

前端 未结 30 1607
南方客
南方客 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

    Just edit /etc/my.cnf Add following lines to my.cnf

    [mysqld]
    
    socket=/var/lib/mysql/mysql.sock 
    
    [client]
    
    socket=/var/lib/mysql/mysql.sock
    

    Restart mysql and connect again

    mysql -u user -p password database -h host;

提交回复
热议问题