How to solve the problem of garbled codes when mysql imports sql from files
Mysql imported from the file sql garbled problem how to solve, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
First of all, I got the sql file without garbled code (you can see the file encoding using the ultraedit administrator interface)
Database coding is consistent with file
Next, let's go into mysql and take a look at variables.
Www.2cto.com
Mysql > show variables like "char%"
+-+
| | 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 | / usr/local/Percona-Server-5.1.57-rel12.8-233--x86_64/share//charsets/ |
+-+
8 rows in set (0.01 sec)
Www.2cto.com
Mysql > show variables like "coll%"
+-+ +
| | Variable_name | Value |
+-+ +
| | collation_connection | latin1_swedish_ci |
| | collation_database | utf8_bin |
| | collation_server | utf8_bin |
+-+ +
3 rows in set (0.00 sec)
There are several latin1's.
The variable that turns out to be connection is latin1... Can't stand it.
Modify the sql file
SET collation_connection = utf8_bin
SET character_set_client = utf8
SET character_set_connection = utf8
Mysql-- socket=/opt/mydata/my3306/my3306.sock-A < xxx.sql would be fine.
After reading the above, do you know how to solve the problem of garbled code when mysql imports sql from the file? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!