Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of garbled codes when mysql imports sql from files

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report