Solution: 1. Use the "set GLOBAL SQL_SLAVE_SKIP_COUNTER=1" statement to skip errors; 2. Add "slave_skip_errors = 1062" under mysqld in the "my.cnf" file and then restart mysql.
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
Mysql During the master-slave replication process, due to various reasons, the slave server may encounter errors in executing SQL in BINLOG. By default , the server will stop the replication process, no longer synchronize, and wait until the user handles it themselves.
slave-skip-errors is used to define error numbers that can be automatically skipped by the slave server during the replication process. When the defined error number is encountered during the replication process, it can be automatically skipped and executed directly. SQL statement
mysql master-slave library synchronization error: 1062 Error 'Duplicate entry '1438019' for key 'PRIMARY'' on query
Mysql master-slave library will occur during synchronization 1062 Last_SQL_Error: Error 'Duplicate entry' problem: Obviously this problem is caused by inserting a duplicate primary key and causing the slave library to not work.
Method 1: You can use this to skip the error
Solution The best way is to execute on the slave library:
mysql> slave stop; mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1; mysql> slave start;
##Method 2: Modify the mysql configuration file and let him skip
Modify the mysql configuration file/etc/my.cnf Add a line slave_skip_errors = 1062 under [mysqld]Save and restart mysqlExtended knowledge:
Some error codes represent errors as follows:The above is the detailed content of How to solve mysql error 1062. For more information, please follow other related articles on the PHP Chinese website!