MySQL Import data Guide data hint duplicate entryfor key error

Source: Internet
Author: User
Tags mysql import phpmyadmin

Before the server data loss decided to move out with phpmyadmin export, because the database file is relatively large, so directly using the MySQL command direct import

MySQL Export Import command
But the results are always there.

ERROR 1062 (23000) at line 1262:duplicate entry '. ꡣh o ' for key 2
And then it stops. Nnd this guy eats soft and doesn't eat hard. Come on, hard. --force. Forced import. Do not exit
# mysql-u Root-p Fukai--force < Dmc010003_db.myisam.sql
Enter Password:
ERROR 1062 (23000) at line 1262:duplicate entry '. ꡣh o ' for key 2
ERROR 1062 (23000) at line 1263:duplicate entry ' m?oʙh m ' for key 2
ERROR 1062 (23000) at line 1271:duplicate entry '? ^΢ц ' for key 2
ERROR 1062 (23000) at line 5182:duplicate entry '. ꡣh o ' for key 2
ERROR 1062 (23000) at line 5187:duplicate entry '? ^΢ц ' for key 2
ERROR 1231 (42000) at line 7268:variable ' Sql_mode ' can ' t being set to the value of ' NULL '

yingouqlj@qljlearnhost:/home/jump$ MySQL uynetwork <z.sql-u root-p
Enter Password:
ERROR 1062 (23000) at line 20449:duplicate entry '?????? ' for key 1 puzzle


After the Internet access to say that use-force Force import

MySQL uynetwork <a.sql-force-u root-p then a large error occurred
But there's still a problem.
Finally found that the original in the phpMyAdmin exported file encoding is the last use of UTF-8

The code is as follows Copy Code

MySQL uynetwork <p.sql-u root-p--default-character-set=utf8

Summarize

Duplicate entry...for Key ... The cause of the error is a duplicate of the primary key's unique value. When a database is modified, inserted, and the unique value of a primary key is repeated, this error is reported, sometimes when multiple primary keys exist in the table, the table operation is still reported as a result of the index of the table. For example, a table has id1,id2 two primary keys, however, when inserting data, there is already a record of ff,11, insert ff,22 Such a record should be no problem, but reported the above error, the reason is that the index only id1 this field index, There is no federated index for ID2, so an error occurs when inserting the ff,22 record.

Processing method: Index_1 in the indexes of the table is processed, and adding another primary key is OK.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.