Bug #72556 Using mysql_secure_installation on master, gives error on slave
Submitted: 7 May 2014 6:25 Modified: 17 Jul 2014 20:37
Reporter: Shahriyar Rzayev Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S1 (Critical)
Version:5.6.17, 5.6.21 OS:Linux (CentOS 6.5)
Assigned to: CPU Architecture:Any

[7 May 2014 6:25] Shahriyar Rzayev
Description:
Dear all,
After setting up fresh MySQL 5.6.17s i setup simple master->slave replication using this procedures:

On Master Server:

mysql> CREATE USER 'repl'@'%' IDENTIFIED BY '$slavepass45#';
Query OK, 0 rows affected (0,00 sec)

mysql> GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repl'@'%';
Query OK, 0 rows affected (0,00 sec)

mysql> CREATE USER 'remote'@'%' IDENTIFIED BY '12345';
Query OK, 0 rows affected (0,00 sec)

mysql> grant all on *.* to 'remote'@'%' with grant option;
Query OK, 0 rows affected (0,00 sec)

On SLave Server:

mysql> CREATE USER 'remote'@'%' IDENTIFIED BY '12345';
Query OK, 0 rows affected (0,00 sec)

mysql> grant all on *.* to 'remote'@'%' with grant option;
Query OK, 0 rows affected (0,00 sec)

On Master server:

mysqldbexport --server=remote:12345@192.168.1.77:3306 --export=both --rpl=master --all --output-file /home/export7.sql --rpl-user=repl:'$slavepass45#' -vvv --bulk-insert --locking=snapshot

* scp /home/export7.sql root@192.168.1.66:/home

On Slave server:

mysql> reset master;
Query OK, 0 rows affected (0,02 sec)

[root@linuxsrv4 ~]# mysqldbimport --server=remote:12345@192.168.1.88:3306 /home/export7.sql
# Source on 192.168.1.88: ... connected.
# Importing definitions from /home/export7.sql.
#...done.

And Slave starts normally it is worked.

But when i use mysql_secure_installation on master side it gives error on slave:
Note: i choose YES for all in mysql_secure_installation script input.

Error from Slave side:
From slave status:

Last_Error: Could not execute Update_rows event on table mysql.user; Can't find record in 'user', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000001, end_log_pos 2008425

From Slave error log:

2014-05-07 11:05:22 3526 [Note] Slave I/O thread: connected to master 'repl@192.168.1.77:3306',replication started in log 'FIRST' at position 4
2014-05-07 11:05:22 3526 [Note] Slave SQL thread initialized, starting replication in log 'FIRST' at position 0, relay log '/var/lib/mysql/data/mysql-relay-bin.000001' position: 4
2014-05-07 11:06:18 3526 [ERROR] Slave SQL: Could not execute Update_rows event on table mysql.user; Can't find record in 'user', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000001, end_log_pos 2008425, Error_code: 1032
2014-05-07 11:06:18 3526 [Warning] Slave: Can't find record in 'user' Error_code: 1032
2014-05-07 11:06:18 3526 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000001' position 2007359

How to repeat:
Install Fresh 2 MySQL 5.6.17. Setup simple replication between them and then run mysql_secure_installation on master side.

Suggested fix:
Maybe not to use mysql_secure_installation on working master and slave?
[17 Jul 2014 20:37] Sveta Smirnova
Thank you for the report.

Indeed mysql_secure_installation does not turn binary log OFF and does not has such an option. If you use row-based replication and your mysql database on slave does not have same data as on master there is a good chance that replication fails. Workaround here is to either temporarily turn binary log OFF on master or skip failed events on slave.

Verified as described.