First, I got the SQL file without garbled characters (the file encoding can be seen on the ultraedit administrator interface)
Database encoding and file consistency
Next we will go to mysql to see 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-Linux-x86_64/share/mysql/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...
It turns out that the connection variable is latin1.
Modify an 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 is fine...
From sunvince's column