mysql数据库做了主、从,当我用insert into my_table values(...)这种命令在主数据库的表中插入数据时,可以同步过去,但是当我用insert into my_table select * from you_table where...这种命令在主数据库的表中插入数据时,却不能同步,是什么原因?

解决方案 »

  1.   

    正常情况下这种应该可以同步的 在你的slave上 show  slave status\G看一下是否复制线程断掉了
      

  2.   

    slave:show slave status\G
    master,slave:show variables like '%format%';把上面2个命令的结果贴出来看看。
      

  3.   


    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.1.220
                      Master_User: rep1
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000074
              Read_Master_Log_Pos: 66655
                   Relay_Log_File: mysqld-relay-bin.000227
                    Relay_Log_Pos: 11559
            Relay_Master_Log_File: mysql-bin.000074
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
                  Replicate_Do_DB: egreen_data_zhuanli_new
              Replicate_Ignore_DB: mysql
               Replicate_Do_Table:
           Replicate_Ignore_Table:
          Replicate_Wild_Do_Table:
      Replicate_Wild_Ignore_Table:
                       Last_Errno: 0
                       Last_Error:
                     Skip_Counter: 0
              Exec_Master_Log_Pos: 66655
                  Relay_Log_Space: 11715
                  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
    Master_SSL_Verify_Server_Cert: No
                    Last_IO_Errno: 0
                    Last_IO_Error:
                   Last_SQL_Errno: 0
                   Last_SQL_Error:
    1 row in set (0.00 sec)+---------------------+-------------------+
    | Variable_name       | Value             |
    +---------------------+-------------------+
    | binlog_format       | STATEMENT         |
    | date_format         | %Y-%m-%d          |
    | datetime_format     | %Y-%m-%d %H:%i:%s |
    | default_week_format | 0                 |
    | time_format         | %H:%i:%s          |
    +---------------------+-------------------+上面为从,下面为主
    +--------------------------+-------------------+
    | Variable_name            | Value             |
    +--------------------------+-------------------+
    | binlog_format            | STATEMENT         |
    | date_format              | %Y-%m-%d          |
    | datetime_format          | %Y-%m-%d %H:%i:%s |
    | default_week_format      | 0                 |
    | innodb_file_format       | Antelope          |
    | innodb_file_format_check | ON                |
    | innodb_file_format_max   | Antelope          |
    | time_format              | %H:%i:%s          |
    +--------------------------+-------------------+
      

  4.   

    日志没有问题。是同步整个数据库?相差的记录确定是
    insert into my_table select * from you_table where... 造成的?
      

  5.   

    Replicate_Do_DB: egreen_data_zhuanli_new先use egreen_data_zhuanli_new;
    再insert into my_table select * from you_table where... 
      

  6.   


    我的意思是,为什么用insert into my_table select * from you_table where...这种方法插入的数据不能同步过去?而insert into ... values...插入的数据可以正常同步?
      

  7.   

    you_table  表在从服务器上有吗? 其中有记录吗?