mysql 从文件导入sql 乱码问题该怎么解决

网友投稿 438 2023-12-10

mysql 从文件导入sql 乱码问题该怎么解决

mysql 从文件导入sql 乱码问题该怎么解决,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

mysql 从文件导入sql 乱码问题该怎么解决

首先我拿到sql文件没乱码,(用ultraedit 管理员界面可以看到文件编码)

数据库编码和文件一致

下面就进到mysql里面看看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) 

有几个latin1的...

原来是connection的变量是latin1... 忍不了

修改sql文件

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 就好了...

看完上述内容,你们掌握mysql 从文件导入sql 乱码问题该怎么解决的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:MySQL出现 Access denied for user ‘root’@localhost’ using password: YES错误该怎么办
下一篇:如何进行mysql乱码产生的探讨
相关文章

 发表评论

暂时没有评论,来抢沙发吧~