PhpMyAdmin solves Chinese garbled data export problems

Source: Internet
Author: User
Tags myadmin

PHPMyAdmin version 2.9.1.1
Back up data with phpMyAdminDatabaseAfter export, use it locallyPHPWhen restoring MyAdmin or sqlyog, the following error occurs:
Error occured at: 10:09:43
Line No.: 11154
Error code: 1062-duplicate entry '?????? 'For key 2

The reason is that the Chinese part of the file content is garbled and all are similar ???,???? Because there are manyProgramThe Chinese user names are supported, and the user names are unique. After the chinese user names become garbled, many identical user names appear, and we import these garbledDataThere are already ?????? This user name is used, so the second one is shown below and an error is reported.

IfSystemYou can use the following command to export data without garbled characters.
MySQLDump-uroot-p -- default-character-set = utf8 -- Set-charset -- skip-opt dbname> newdbname. SQL

But now can only use phpMyAdmin export, test for a long time, found that if phpMyAdmin language is "Chinese-Chinese simplified-gb2312", export the SQL file is gb2312, some tables have Chinese, chinese characters are garbled. When the Laguage of phpMyAdmin is "Chinese-Chinese Simplified(That is, utf8) ", the exported SQL file character set is utf8 (with notepad ++ to view the format, the display is UTF-8 without BOM format encoding ), the Chinese characters in the table can be displayed normally.

to prevent Chinese characters from being garbled in exported files, select Chinese-Chinese Simplified from the language drop-down menu, and then select export, the Chinese characters in the downloaded SQL file can be displayed normally.
use the following command to restore
mysql-uroot-p -- default-character-set = utf8 newdbname
I originally wanted to change the default language of phpMyAdmin to "Chinese-Chinese ". simplified ", however, I tried to modify config. inc. config. default. PHP are useless, it doesn't matter, after all, different people choose the database encoding are not the same, there is always someone to re-choose the language, or let it default is "Chinese-Chinese simplified-gb2312!
Another solution is to guess that the exported file code is gb2312, so you can consider converting gb2312 to utf8. this method is being tested.

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.