ITeye博客

linux导出数据库报错:Can't connect to local MySQL server through socket '/tmp/mysql.sock

MNTMs · 2015-06-03 19:23 · mysql · linux · 编程语言 · Markdown

在执行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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。