title: GTID replication failing error 1062
body: <p>I am having trouble setting up a slave replication. Both use mysql 5.6 and have GTID on. Master is on rackspace's cloud databases HA instance</p>
  
  <p>The dump I include has a GTID on it and the master.</p>
  
  <p>I enabled GTID on slave by adding the following to the slave (i didn't have it on). I then deleted all the databases so it was fresh.</p>
  
  <pre><code>gtid_mode=ON
  enforce_gtid_consistency=true
  log_bin=/Library/Application Support/appsolute/MAMP PRO/db/mysql56/log
  log_slave_updates=true
  binlog_format=mixed
  </code></pre>
  
  <p>Commands I ran:</p>
  
  <pre><code>mysqldump  --tz-utc=false -u root -pPASSWORD --host=HOST --all-databases &gt; dump.sql
  
  mysql&gt;CHANGE MASTER TO MASTER_HOST = 'MASTER_HOST', MASTER_PORT = 3306, MASTER_USER = 'repl_user', MASTER_PASSWORD = 'PASSWORD', MASTER_AUTO_POSITION = 1;
  mysql&gt;reset master;
  mysql&gt;source dump.sql;
  mysql&gt;start slave;
  
  
  mysql&gt; show slave status \G
  *************************** 1. row ***************************
                 Slave_IO_State: Waiting for master to send event
                    Master_Host: IP
                    Master_User: repl_user
                    Master_Port: 3307
                  Connect_Retry: 60
                Master_Log_File: replica-2053073453-bin.000026
            Read_Master_Log_Pos: 1022001275
                 Relay_Log_File: mysql-relay-bin.000002
                  Relay_Log_Pos: 7600
          Relay_Master_Log_File: replica-2053073453-bin.000026
               Slave_IO_Running: Yes
              Slave_SQL_Running: No
                Replicate_Do_DB: 
            Replicate_Ignore_DB: 
             Replicate_Do_Table: 
         Replicate_Ignore_Table: 
        Replicate_Wild_Do_Table: 
    Replicate_Wild_Ignore_Table: 
                     Last_Errno: 1062
                     Last_Error: Error 'Duplicate entry '0db833be2a27f7fac7fa3ee1165256a398b7065f' for key 'PRIMARY'' on query. Default database: 'phppoint_demo2'. Query: 'INSERT INTO `phppos_sessions` (`id`, `ip_address`, `timestamp`, `data`) VALUES ('0db833be2a27f7fac7fa3ee1165256a398b7065f', 'IP', 1487705858, '')'
                   Skip_Counter: 0
            Exec_Master_Log_Pos: 1018575999
                Relay_Log_Space: 3433080
                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: NULL
  Master_SSL_Verify_Server_Cert: No
                  Last_IO_Errno: 0
                  Last_IO_Error: 
                 Last_SQL_Errno: 1062
                 Last_SQL_Error: Error 'Duplicate entry '0db833be2a27f7fac7fa3ee1165256a398b7065f' for key 'PRIMARY'' on query. Default database: 'phppoint_demo2'. Query: 'INSERT INTO `phppos_sessions` (`id`, `ip_address`, `timestamp`, `data`) VALUES ('0db833be2a27f7fac7fa3ee1165256a398b7065f', 'IP', 1487705858, '')'
    Replicate_Ignore_Server_Ids: 
               Master_Server_Id: 2053073453
                    Master_UUID: 979f153e-2d80-11e6-bb91-00185119e861
               Master_Info_File: /Library/Application Support/appsolute/MAMP PRO/db/mysql56/master.info
                      SQL_Delay: 0
            SQL_Remaining_Delay: NULL
        Slave_SQL_Running_State: 
             Master_Retry_Count: 86400
                    Master_Bind: 
        Last_IO_Error_Timestamp: 
       Last_SQL_Error_Timestamp: 170221 14:55:55
                 Master_SSL_Crl: 
             Master_SSL_Crlpath: 
             Retrieved_Gtid_Set: d2ce9c03-2d7f-11e6-bb8c-001851fe939d:10115103-10119980
              Executed_Gtid_Set: 979f153e-2d80-11e6-bb91-00185119e861:1-17,
  d2ce9c03-2d7f-11e6-bb8c-001851fe939d:1-10115113
                  Auto_Position: 1
  </code></pre>
  
  <p>I followed steps at: (How to restore a slave in a good and slow way) </p>
  
  <p><a href="https://www.percona.com/blog/2013/02/08/how-to-createrestore-a-slave-using-gtid-replication-in-mysql-5-6/" rel="nofollow noreferrer">https://www.percona.com/blog/2013/02/08/how-to-createrestore-a-slave-using-gtid-replication-in-mysql-5-6/</a></p>