就我而言,我在从单主模式 MySQL 复制组恢复备份时遇到了同样的错误。我在cmd--single-transaction
期间使用标志进行了备份。mysqldump
$ mysqldump -uroot -p<root_password> -h<host> --set-gtid-purged=OFF --single-transaction --all-databases --triggers --routines --events < dump.sql
在这里,查看--single-transaction
flag 的用法以了解它导致的问题。
$ mysqldump --help
...
--single-transaction
Creates a consistent snapshot by dumping all tables in a
single transaction. Works ONLY for tables stored in
storage engines which support multiversioning (currently
only InnoDB does); the dump is NOT guaranteed to be
consistent for other storage engines. While a
--single-transaction dump is in process, to ensure a
valid dump file (correct table contents and binary log
position), no other connection should use the following
statements: ALTER TABLE, DROP TABLE, RENAME TABLE,
TRUNCATE TABLE, as consistent snapshot is not isolated
from them. Option automatically turns off --lock-tables.
...
因此,在阅读了@RickJames 提供的建议后,我只是在备份期间--single-transaction
从 cmd 中删除了标志mysqldump
,然后将其恢复到新的复制组。
注意: MySQL 服务器版本为 5.7.25