Mysql 8.0.22 master slave replication: why slave is trying to create user

dockermaster-slave-replicationmysql-8.0

I am following this repo (https://github.com/alexanderfefelov/docker-mysql-replication) to setup one master one slave replication. I am not able to get it working. The master seems to be OK, but the slave has the following error:


mysql_slave1.1.ydo3yuvbyibc@64g-480g-node2    | 2020-12-22T23:19:42.284061Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.22'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
mysql_slave1.1.ydo3yuvbyibc@64g-480g-node2    | 2020-12-22T23:19:42.285009Z 5 [System] [MY-010562] [Repl] Slave I/O thread for channel '': connected to master 'replicator@mysql_master:3306',replication started in log 'log-bin.000023' at position 156
mysql_slave1.1.ydo3yuvbyibc@64g-480g-node2    | 2020-12-22T23:19:42.289356Z 6 [ERROR] [MY-010584] [Repl] Slave SQL for channel '': Error 'Operation CREATE USER failed for 'replicator'@'%'' on query. Default database: ''. Query: 'CREATE USER 'replicator'@'%' IDENTIFIED WITH 'mysql_native_password' AS '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19'', Error_code: MY-001396
mysql_slave1.1.ydo3yuvbyibc@64g-480g-node2    | 2020-12-22T23:19:42.289425Z 6 [Warning] [MY-010584] [Repl] Slave: Operation CREATE USER failed for 'replicator'@'%' Error_code: MY-001396
mysql_slave1.1.ydo3yuvbyibc@64g-480g-node2    | 2020-12-22T23:19:42.289442Z 6 [ERROR] [MY-010586] [Repl] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'log-bin.000016' position 3107328

The master already created user replicator during start up, why slave also tries to create this user?

Thanks!

Best Answer

Found the issue. It was caused by the left over binlog. I externalized the binlog folder, after delete binlog folder on the host and start again, it worked.