对一个运行很久的库做备份恢复建同步
不能使用xtrabackup
使用mysqldump导数据:
mysqldump -S /data/mysql/3307/tmp/3307.sock --single-transaction --master-data=2 --databases lgj3307 > lgj3307.sql
在从库上执行:
change master to master_host='192.168.56.156',master_user='repl',master_password='oracle',master_port=3306,MASTER_AUTO_POSITION = 1 for channel 'master-1563306';
mysql -S /data/mysql/3306/tmp/3306.sock < lgj3307.sql
导入时,发生如下错误:
ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty.
mysql -f -S /data/mysql/3306/tmp/3306.sock < lgj3307.sql
-f的作用:强制导入。