在执行mysqldump命令时候报如下错误:
[root@localhost ~]# mysqldump -uroot -p******* --all-databases> all.sql
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/data/mysql/mysql.sock' (2) when trying to connect
找到正确的套接字的路径:
[root@localhost ~]# netstat -ln | grep mysql
unix 2 [ ACC ] STREAM LISTENING 2447213870 /data/mysql/data/mysql.sock
再运行dump命令:
mysqldump --socket=/data/mysql/data/mysql.sock -uroot -hlocalhost -p***** db_err_2017 >/data/mysql/da_err_2017.sql
转载自:https://blog.csdn.net/seteor/article/details/18356079