How to import Chinese garbled characters in SQL under NavicatPremium
When I asked a friend for a bug today, I was ready to import the data in her database, so I tried to import the corresponding mysql command under the mysql management tool Navicat. The result shows that all the Chinese characters imported are garbled, so the following attempt is made:
In "connection property" Settings, advanced-remove the hook from "use mysql Character Set" and change the encoding to 10008-GB2312.
Then go to the navicat console and run the show variables like 'Char % 'command as follows:
+--------------------------+---------------------------------------+| Variable_name | Value |+--------------------------+---------------------------------------+| character_set_client | latin1 || character_set_connection | latin1 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | latin1 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | D:\mysql-5.1.32-win32\share\charsets\ |
In this case, run the set names 'gbk' command on the console and show variables like 'Char % 'again. The result is as follows:
+--------------------------+---------------------------------------+| Variable_name | Value |+--------------------------+---------------------------------------+| character_set_client | gbk || character_set_connection | gbk || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | gbk || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | D:\mysql-5.1.32-win32\share\charsets\ |
The client connection environment is complete. Then, how to insert Chinese data or how to insert it will not be garbled.
To import data in batches from. SQL .txt and other texts, You need to convert the corresponding file into gbk format and save it before importing it. Otherwise, garbled characters will occur after the import.
If the output encoding format is not the above format, you can also modify it using the following SQL statement. MYSQL Command sets the encoding format: set character_set_server = 'utf8 ';