MySQL Replication failing on `mysql`.`user` changes

I have a simple master - slave setup with MySQL 5.6 that keeps failing whenever I make changes to the mysql.user table. The master is set to replicate two databases, neither of which are the mysql database. The binlog_format is set to ROW.

I have a selection of MySQL users set up on the master for various colleagues to make changes to the database on, but on the slave I only have one user, which is the web server.

When I tried to delete a redundant user from the master, the slave failed with the following message:

Error 'Operation DROP USER failed for 'mysql_user'@'localhost'' on query. Default database: ''. Query: 'DROP USER 'mysql_user'@'localhost''

I don't want to have to keep skipping the errors, because every now and again I'll make changes to the mysql.user table and it's easy to forget to check the replication is still going. I don't have any monitoring setup for the replication, so a couple of times I've made changes to the mysql table and no one has noticed for a couple of hours, which impacts our production web server.

Any help much appreciated.

0
задан 27 July 2017 в 16:27
1 ответ

Обратите внимание на часть сообщения об ошибке: 'mysql_user' @ 'localhost' '

После слова localhost есть две кавычки. Когда этот оператор реплицируется, подчиненный сервер базы данных не может найти пользователя, и репликация останавливается. MySQL 5.7 имеет форму DROP USER IF EXISTS user , но в MySQL 5.6 вам лучше не делать таких ошибок или предпочитать прямое редактирование базы данных mysql.

ОБНОВЛЕНИЕ: когда вы не заинтересованы в репликации учетных записей MySQL из от главного сервера к подчиненным, вы можете добавить replicate-ignore-db = mysql в разделы [mysqld] на каждом подчиненном устройстве .Я предпочитаю фильтрацию на ведомых устройствах, поскольку изменения в двоичных журналах ведущего устройства потенциально могут быть полезны для устранения неполадок в будущем.

1
ответ дан 4 December 2019 в 16:11

Теги

Похожие вопросы