Real mysql export Chinese garbled code and phpmyadmin import Chinese garbled code solution

  • 2020-03-31 20:54:18
  • OfStack

Has not used this phpmyadmin, in the machine is also using navicat, phpmyadmin always feel slower speed. Not this time, no independent host, have to use someone else's phpmyadmin.

Step 1: export the SQL file from the local data. Thought it was a piece of cake for navicat. Right click on the database to "dump SQL" (as shown in figure 1).

< img Alt = "" border = 0 height = 338 SRC =" http://files.jb51.net/upload/201006/20100611010533735.jpg "width = 257 border = 0 >

( Figure 1: navicat SQL against the entire database )

With notepad open a look, dumbfounded. Chinese is full of garbled characters. What happened? Did a little bit of a search, changed what connection properties what. It doesn't work. Try dumping SQL on a single table, hey, Chinese normal. But with 82 watches, I dump them one by one and I'm not dead. I can't. I guess I'll have to ditch my beloved navicat. Think of a mysqldump so you can try it. Run-c :\Documents and Settings\Administrator> The mysqldump uroot - p123   Ttg> Ttgbk2. SQL. Open a look, or garbled code. Not yet. Well.. Search, change the following to add the specified character set

C: \ Documents and Settings \ Administrator> Mysqldump-uroot-p123 --default-character-set= GBK ttg> Ttgbk2. SQL. Open it. Hey, that's it.

 

Step 2: open the phpmyadmin.import selection file provided by the virtual host ttgbk2. SQL. That speed, uh... An error was reported. When executing lock tables tablename write, an access denied error occurred. It turns out that I am a virtual host user without the permission of lock tables. I don't have permission to do that. I went to the Internet and said, "skip-lock-tables"

Add the -skip-lock-tables option to mysqldump, and the command line becomes
C: \ Documents and Settings \ Administrator> Mysqldump-uroot-p123 --default-character-set= GBK --skip-lock-tables ttg> Ttgbk3. SQL.
The results were disappointing, but there was lock tables.
Then I looked at mysqldump --help
Just to understand --skip-lock-tables is used to prevent reading and writing during backup. But if you don't want to export with lock-tables (because you don't have permission to import them, hehe) you should use add-locks=false, which is two concepts. The correct ones are as follows
C: \ Documents and Settings \ Administrator> Mysqldump uroot - p123 - default -- character set GBK = TTG - add - the locks = false> Ttgttg3. SQL.

My version of the export opens in notepad in asni format.

Import again at phpmyadmin. The result is an error after importing three tables. Error reported by mysql statement. A look at the Chinese also garbled code... Near collapse.

Find out why. Change "MySQL connection collate" to gbk-chinese-ci and language to chinese-chinese simplified(figure 2). Then import "file code" to "GBK" (the default is utf-8, of course the corresponding SQL file code opened with notepad is ANSI.)(see figure 3). Try again...

 

 

< img border = 0 SRC = "http://files.jb51.net/upload/201006/20100611010657593.gif" border = 0 >

( Figure 2: modify connection collation and language )

 

< img Alt = "" border = 0 height = 406 SRC =" http://files.jb51.net/upload/201006/20100611010533590.jpg "width = 598 border = 0 >

( Figure 3: change the character set of the file to GBK )

 

Finally all the tables were imported successfully. Open a table containing Chinese, the field shows normal.

2 points to learn:

1. Database coding belongs to database coding. Make sure the connection check is consistent with the database code.

2, SQL file encoding file encoding. It is best to ensure that the file encoding selected when importing is consistent with the encoding used by the database.

These are two coding problems.

Thank you for mysql. You've been like this ever since you knew you had this coding problem. This question still confuses many people. When like sqlserver internationalization is good.


Related articles: