mysqldump导出报错问题
在执行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