共计 1683 个字符,预计需要花费 5 分钟才能阅读完成。
一天老大要求做 MySQL5.6 的数据库的主从复制,,但是报错了,提示 1050 数据表已存在错误:
Last_SQL_Errno: 1050
Last_SQL_Error: Error ‘Table ‘authWeibo’ already exists’ on query. Default database: ‘novel’. Query: ‘CREATE TABLE `authWeibo` (
`userId` int(11) unsigned NOT NULL AUTO_INCREMENT,
`unionId` varchar(100) DEFAULT NULL,
PRIMARY KEY (`userId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4′
[root@localhost log]# tailf error.log
2017-08-10 23:19:30 10076 [Note] Slave I/O thread: connected to master ‘novelrep@192.168.10.98:3306’,replication started in log ‘FIRST’ at position 4
2017-08-10 23:19:30 10076 [Warning] Slave SQL: If a crash happens this configuration does not guarantee that the relay log info will be consistent, Error_code: 0
2017-08-10 23:19:30 10076 [Note] Slave SQL thread initialized, starting replication in log ‘FIRST’ at position 0, relay log ‘./localhost-relay-bin.000001’ position: 4
2017-08-10 23:49:50 10076 [ERROR] Slave SQL: Error ‘Table ‘authWeibo’ already exists’ on query. Default database: ‘novel’. Query: ‘CREATE TABLE `authWeibo` (
`userId` int(11) unsigned NOT NULL AUTO_INCREMENT,
`unionId` varchar(100) DEFAULT NULL,
PRIMARY KEY (`userId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4′, Error_code: 1050
2017-08-10 23:49:50 10076 [Warning] Slave: Table ‘authWeibo’ already exists Error_code: 1050
2017-08-10 23:49:50 10076 [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.000073’ position 1025057034
解决办法:
slave 从库上停止从库复制线程,重置从库复制账户信息和同步失败的 binlog 文件以及同步失败的 binglog 位置点:
stop slave;
reset slave;
CHANGE MASTER TO MASTER_HOST=’192.168.10.98′,MASTER_PORT=3306,MASTER_USER=’novelrep’,MASTER_PASSWORD=’JuwoSdk21TbUser’,master_log_file=’mysql-bin.000073
‘,master_log_pos=1025057034;start slave;show slave status\G
到此同步成功
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-08/146203.htm