Mysql SQL garbled characters imported from files...

Source: Internet
Author: User

 

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

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.