Home > Database > Mysql Tutorial > How to solve mysql error 1062

How to solve mysql error 1062

WBOY
Release: 2022-05-26 18:14:40
Original
15033 people have browsed it

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.

How to solve mysql error 1062

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How to solve mysql error 1062

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;
Copy after login

How to solve mysql error 1062

##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 mysql

Extended knowledge:

Some error codes represent errors as follows:

  • 1007: The database already exists, failed to create the database

  • 1008: The database does not exist. Deleting the database failed.

  • 1050: The data table already exists. Creating the data table failed.

  • 1051: Data The table does not exist, and deletion of the data table failed

  • 1054: The field does not exist, or the program file conflicts with the database

  • 1060: The field is duplicated, Failed to insert

  • 1061: Duplicate key name

  • 1068: Multiple primary keys defined

  • 1094: Location thread ID

  • 1146: The data table is missing, please restore the database

  • 1053: The main server is down during the replication process

  • 1062: Primary key conflict Duplicate entry '%s' for key %d

Recommended learning:

mysql video tutorial

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template