mysqldump匯出時報2002 套接字錯誤
阿新 • • 發佈:2018-12-23
在執行mysqldump命令時候報如下錯誤:
[[email protected] ~]# mysqldump -uroot -p -d test> test.sql
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect
找到正確的套接字的路徑:
[[email protected] ~]# netstat -ln | grep mysql
unix 2 [ ACC ] STREAM LISTENING 70442911 /MysqlData/base/mysql/mysql.sock
再執行dump命令:
[ [email protected] ~]# mysqldump --sock=/MysqlData/base/mysql/mysql.sock -uroot -p -d test> test.sql
Warning: Using unique option prefix sock instead of socket is deprecated and will be removed in a future release. Please use the full name instead.
[[email protected] ~]# mysqldump -uroot -p -d test> test.sql
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect
找到正確的套接字的路徑:
[[email protected] ~]# netstat -ln | grep mysql
unix 2 [ ACC ] STREAM LISTENING 70442911 /MysqlData/base/mysql/mysql.sock
再執行dump命令:
[
Warning: Using unique option prefix sock instead of socket is deprecated and will be removed in a future release. Please use the full name instead.
Enter password:
執行成功,但有警告資訊,提示使用sock前輟將在後繼版本中可能不再支援,請使用全名
將--sock 換成--socket將不再有問題:
[[email protected] ~]# mysqldump --socket=/MysqlData/base/mysql/mysql.sock -uroot -p -d test> test.sql