由于我没有足够的声誉在最高帖子之后发表评论,所以我在这里添加。
使用“|”在linux平台上以节省磁盘空间。
感谢@Hariboo,添加事件/触发器/程序参数
mysqldump -x -u [uname] -p[pass] -C --databases db_name --events --triggers --routines | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/ ' | awk '{ if (index($0,"GTID_PURGED")) { getline; while (length($0) > 0) { getline; } } else { print $0 } }' | grep -iv 'set @@' | trickle -u 10240 mysql -u username -p -h localhost DATA-BASE-NAME
一些问题/提示:
错误:......使用 LOCK TABLES 时不存在
# --lock-all-tables,-x , this parameter is to keep data consistency because some transaction may still be working like schedule.
# also you need check and confirm: grant all privileges on *.* to root@"%" identified by "Passwd";
ERROR 2006 (HY000) at line 866: MySQL server has gone away
mysqldump:写入时出现 errno 32
# set this values big enough on destination mysql server, like: max_allowed_packet=1024*1024*20
# use compress parameter '-C'
# use trickle to limit network bandwidth while write data to destination server
第 32730 行的错误 1419 (HY000):您没有 SUPER 权限并且启用了二进制日志记录(您可能想要使用不太安全的 log_bin_trust_function_creators 变量)
# set SET GLOBAL log_bin_trust_function_creators = 1;
# or use super user import data
第 138 行的错误 1227 (42000):访问被拒绝;您需要(至少一个)超级权限才能执行此操作
mysqldump:写入时出现 errno 32
# add sed/awk to avoid some privilege issues
希望对您有所帮助!