mysql错误ERROR 1062 (23000) Duplicate entryfor key 2

date:星期二, 一月 5th, 2010 at 6:00 下午 Categories:mysql

之前服务器数据丢失后决定搬家了
用PHPMYADMIN导出
因为数据库文件比较大
所以直接使用MYSQL命令直接导入

相关请翻阅以前的两片摘录
MYSQL导入导出工具mysqldump详细手册

MySQL导出导入命令
但是结果却不断的出现

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

费解
上网查阅后有说使用-FORCE 强制导入

mysql uynetwork <a.sql -force -u root -p

然后出现一大段错误
但是还是存在问题
最后发现原来在PHPMYADMIN导出的时候文件编码是UTF-8的
最后使用

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

One Response to “mysql错误ERROR 1062 (23000) Duplicate entryfor key 2”

  1. 愛鄰搬家No Gravatar

    It is the best time to make some plans for the long run and it’s time to be happy. I’ve read this post and if I may I wish to recommend you some interesting issues or suggestions. Perhaps you can write subsequent articles referring to this article. I want to learn even more issues approximately it!

    [Reply]

Leave a Reply