mysql5.7版本、linux下
mysqldump备份数据库
[root@localhost bin]# ./mysqldump -uroot -p -A --compatible=oracle > /mnt/mysql/all.sql
Enter password:
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect
查看mysql服务的mysql.sock地址
[root@localhost bin]# netstat -ln | grep mysql
unix 2 [ ACC ] STREAM LISTENING 25564 /mnt/mysql/mysql57/mysql.sock
加上socket
[root@localhost bin]# ./mysqldump --socket=/mnt/mysql/mysql57/mysql.sock -uroot -p -A --compatible=oracle > /mnt/mysql/all.sql
Enter password:
[root@localhost bin]#