Mysql复制数据库UPDATE不能正常工作

我一直在尝试在MySQL数据库中启动复制。 我遵循MySQL手册中的所有步骤来设置和configuration复制。

http://dev.mysql.com/doc/refman/5.1/en/replication-howto.html

我可以毫无困难地开始复制。 新插入的数据被正确复制。 但过了一段时间,我发现虽然INSERT正在工作,但UPDATE不能复制。 所以,我的复制数据库就像第一次插入数据一样。

我的主数据库在MySQL-5.1.56的UNIX服务器上。 从属在Windows中使用WAMP包与MySQL 5.5.8。 我也尝试过使用WAMP5的低版本MySQL的slave,效果相同。

请分享你的想法和经验。 谢谢。

在奴隶,你应该运行命令SHOW SLAVE STATUS

它将提供有关失败原因的信息;

 mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: master.db.sever Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000154 Read_Master_Log_Pos: 209998 Relay_Log_File: mysqld-relay-bin.000480 Relay_Log_Pos: 105395 Relay_Master_Log_File: mysql-bin.000154 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: mysql Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 <-----here this value Last_Error: <-----here this value Skip_Counter: 0 Exec_Master_Log_Pos: 209998 Relay_Log_Space: 105395 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 1 row in set (0.00 sec) 

你对Last Errno感兴趣,看看它的确是0,最后一个错误信息的内容。

据推测,你也可以检查你的复制用户在它应该复制到的表上有“INSERT”和“UPDATE”权限。 这些信息在mysql数据库中,可以用SHOW GRANTS语句检查;

 mysql> show grants for root@'someserver.com'; +---------------------------------------------------------------------------------------+ | Grants for root@someserver | +---------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'oomeserver ' WITH GRANT OPTION | +---------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) 

我在几个月前把它整理出来了。 问题是,我试图复制只有一个单一的数据库,并在master中设置binlog_do_dbbinlog-ignore-db选项来只select该数据库。 但是遗漏了没有使用USE数据库select数据库的任何语句。 在slave上使用replicate-ignore-dbreplicate-do-db选项也是一样的。 所以我最终通过使用slave中的replicate-wild-do-table选项来解决这个问题 。 从服务器的configuration中增加了以下内容。

 replicate-wild-do-table=mydb.%