Error 'Cannot add or update a child row: a foreign key constraint fails (`oddsmatrixdb/#sql-5869_f1ac`, CONSTRAINT `v` FOREIGN KEY (`accountId`) REFERENCES `AccountEntity` (`id`))' on query. Default database: 'oddsmatrixdb'. Query: 'ALTER TABLE `TransactionEntity` ADD CONSTRAINT `v` FOREIGN KEY(`accountId`) REFERENCES `oddsmatrixdb`.`AccountEntity`(`id`)'现在我把主机的show master得到之后从机
slave stop
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.00002’,MASTER_LOG_POS=896292193;发现失败 
Slave_IO_State: 
                Master_Host: 192.168.10.14
                Master_User: replication
                Master_Port: 3306
              Connect_Retry: 60
            Master_Log_File: mysql-bin.00002,MASTER_LOG_POS=896292193
        Read_Master_Log_Pos: 899410406
             Relay_Log_File: relay.000001
              Relay_Log_Pos: 98
      Relay_Master_Log_File: mysql-bin.00002,MASTER_LOG_POS=896292193
           Slave_IO_Running: No
          Slave_SQL_Running: Yes
[16:49:22] Ovidiu Stroe 说: nope
[16:49:24] Ovidiu Stroe 说: not running
[16:49:59] Ovidiu Stroe 说: 090701 10:48:07 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.00002,MASTER_LOG_POS=896292193' at position 899410406, relay log '/var/log/mysqld/relay.000001' position: 98
090701 10:48:07 [Note] Slave I/O thread: connected to master '[email protected]:3306',  replication started in log 'mysql-bin.00002,MASTER_LOG_POS=896292193' at position 899410406
090701 10:48:07 [ERROR] Error reading packet from server: Could not find first log file name in binary log index file ( server_errno=1236)
090701 10:48:07 [ERROR] Got fatal error 1236: 'Could not find first log file name in binary log index file' from master when reading data from binary log
090701 10:48:07 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.00002,MASTER_LOG_POS=896292193', position 899410406
急切 不知道如何解决 

解决方案 »

  1.   

    问题还是艰难解决。
    提示解决思路:
    /var/log/mysql
    下面 mysqlbinlog   ....  /grep '# at'>ss.txt
    之后vi看到附近的 MASTER_LOG_POS   (不能选择最新的) 而要选择之后的
    如果最新的意义不是太大 ,数据好多丢失。
    数据复制环境下 的 建立新表  或者外键 非常容易导致不可思议的错误 。
      

  2.   

    。如果从机与主机有相同的数据,不就没有这个外键的问题了吗?
    CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.00002’,MASTER_LOG_POS=896292193; 
    你的做法是重新指定一个log文件让从机去读,又不改log index,当然不行。“之后vi看到附近的 MASTER_LOG_POS  (不能选择最新的) 而要选择之后的 ”,这个方法感觉本质和上面无异,也是重新找一个新位置开始复制,应该一样会出外键的问题呀。
      

  3.   

    “应该一样会出外键的问题”---
    感谢关注这个难题。
    我初步想法是 停从机, 之后快速分别在主从机上 分别建立 pk fk
    之后再启动从机,这样保证同步(否则还是会出现那个错误)。