在執行mysqldump命令時候報如下錯誤: [root@localhost ~]# mysqldump -uroot -p -d test> test.sql mysqldump: Got error: 2002: Can't connect to local MySQL server throu ...
在執行mysqldump命令時候報如下錯誤:
[root@localhost ~]# 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
找到正確的套接字的路徑:
[root@localhost ~]# netstat -ln | grep mysql
unix 2 [ ACC ] STREAM LISTENING 70442911 /MysqlData/base/mysql/mysql.sock
再運行dump命令:
[root@localhost ~]# 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.
Enter password:
執行成功,但有警告信息,提示使用sock前輟將在後繼版本中可能不再支持,請使用全名
將--sock 換成--socket將不再有問題:
[root@localhost ~]# mysqldump --socket=/MysqlData/base/mysql/mysql.sock -uroot -p -d test> test.sql