mysql在不开启binlog的情况下导出数据库

问题背景

上个DBA已经走了,一些mysql数据库连所在服务器的系统账户也没有,只有mysql 数据库的root账户和业务账户,准备导出数据迁移至新服务器,可是mysqldump命令却是必须开启binlog日志才能导出,而binlog日志的开启依赖于配置文件log-bin参数,需要登录服务器修改配置文件并重启数据库才行。

mysqldump -h172.20.17.95 -uroot -pReapal@2017 --set-gtid-purged=OFF --lock-tables --add-drop-table -E --flush-logs --triggers --routines --events --master-data=2 testdb > test_20171206.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Error: Binlogging on server not active

解决方案

mysql5.7之后推出了mysqlpump命令,相比mysqldump,它可以在不开启binlog的情况下备份数据,另外该命令还支持排除数据库或表进行备份
mysqlpump -h172.20.17.95 -uroot -pReapal@2017 --set-gtid-purged=OFF --single-transaction --add-drop-table --triggers --routines --events -B testdb> testdb_20171206.sql

-B, --databases Dump several databases. Note the difference in usage; in
this case no tables are given. All name arguments are
regarded as database names. 'USE db_name;' will be
included in the output.

原文地址:https://www.cnblogs.com/automng/p/7992526.html