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

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

    Most likely mysql.sock does not exist in /var/lib/mysql/.

    If you find the same file in another location then symlink it:

    For ex: I have it in /data/mysql_datadir/mysql.sock

    Switch user to mysql and execute as mentioned below:

    su mysql
    
    ln -s /data/mysql_datadir/mysql.sock /var/lib/mysql/mysql.sock
    

    That solved my problem

提交回复
热议问题