How to export Chinese garbled characters from mysql and import Chinese garbled characters from phpmyadmin _ PHP Tutorial

Source: Internet
Author: User
How to export Chinese garbled characters in mysql and import Chinese garbled characters in phpmyadmin. Phpmyadmin is never used, and navicat is also used on the local machine. phpmyadmin is always slow. This is not the case. if there is no independent host, you have to use phpmyadmin. Step 1: phpmyadmin is not used locally, and navicat is also used on the local machine. it seems that phpmyadmin is slow. This is not the case. if there is no independent host, you have to use phpmyadmin.

Step 1: export SQL files from local data. I thought this was a breeze for navicat. Right-click the database and choose "dump SQL" (1). the export is successful in over 10 seconds.

(: Convert the entire database to SQL under navicat)

I opened it in notepad, and it was dumpfounded. Chinese characters are all garbled characters. What's going on? After searching, I changed the connection attributes. No matter. Try to dump the SQL statement on a single table. Hey, Chinese is normal. But for 82 tables, I am not exhausted by dumping them one by one. No. It seems that I can only discard my beloved navicat. Think of a mysqldump. try it. Run-C: \ Documents and Settings \ Administrator> mysqldump-uroot-p123 ttg> ttgbk2. SQL. Check whether it is garbled. Not yet. Alas .. Search, change to the following with the specified character set

C: \ Documents and Settings \ Administrator> mysqldump-uroot-p123 -- default-character-set = gbk ttg> ttgbk2. SQL. Open it. Hey, you can.

Step 2: Open phpmyadmin provided by the VM. import the selected ttgbk2. SQL file and click execute. That speed, alas... An error is reported later. The access denied error occurs when you execute lock tables tablename write. Originally, I am a VM user and do not have the permission to lock tables. the lock tables option is available when you open the SQL statement. If you do not have the permission, you do not need to use this. I searched the internet and added -- skip-lock-tables. I thought it was good. it should be the "skip lock table ".

When the-skip-lock-tables option is added to mysqldump, the command line becomes
C: \ Documents and Settings \ Administrator> mysqldump-uroot-p123 -- default-character-set = gbk -- skip-lock-tables ttg> ttgbk3. SQL.
The results are disappointing, but there is still lock tables.
Next, let's take a look at mysqldump -- help.
Only then can we understand that -- skip-lock-tables is used to prevent reading and writing during backup. However, if you do not want to export a lock-tables File (because you do not have the permission during import, huh, huh), you should use add-locks = false, which is two concepts. Correct:
C: \ Documents and Settings \ Administrator> mysqldump-uroot-p123 -- default-character-set = gbk ttg -- add-locks = false> ttgttg3. SQL.

My versions are exported in asni format in Notepad.

Import it again at phpmyadmin. The result is an error after three tables are imported. Mysql statement error. Chinese characters are garbled ..... Close to crash.

Find the reason. Change "MySQL connection verification" to gbk-chinese-ci, and change "language" to chinese-chinese simplified (2 ). Change "file encoding" during import to "gbk" (the default value is utf-8. of course, the corresponding SQL file encoding is opened in notepad by ansi .) (3 ). try again ....

(: Modify Connection Verification and language)

(: Modify the character set of the file to gbk.)

Finally, all tables are successfully imported. Open a table containing Chinese characters, and the field is displayed normally.

2 experiences:

1. database encoding: database encoding. Ensure that the connection verification is consistent with the database encoding.

2. the SQL file encoding is file encoding. Ensure that the file encoding selected during import is the best as the encoding used by the database.

This is two encoding problems.

I got your mysql server. from knowing that you have this encoding problem till now, you still look like this. This problem is still confusing to many people. When will it be as international as SQL server.

Bytes. This is not the case. if there is no independent host, you have to use phpmyadmin. Step 1: local...

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.