1. 程式人生 > >Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when tryin

Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when tryin

在linux環境下將mysql中某個表匯出為sql指令碼,執行命令:

mysqldump -uroot -p密碼 liqun i_billmain --where="czsj>'2018-07-24 00:00:00'" > /home/mysql/main-20180724.sql

時報錯:

mysqldump: Got error: 2002: Can't connect to local
 MySQL server through socket '/tmp/mysql.sock' (2)
 when trying to connect

解決:修改命令

mysqldump -h127.0.0.1 -uroot -p密碼 liqun i_billmain
 --where="czsj>'2018-07-24 00:00:00'" > /home/mysql/main-20180724.sql

OK