首页 > 代码库 > Mysql客户端中文乱码问题解决
Mysql客户端中文乱码问题解决
用Mysql客户端查询发现乱码:
mysql> select * from user;
+----+------------+----------+------------+-----------+
| id | nickname | password | first_name | last_name |
+----+------------+----------+------------+-----------+
| 1 | chaoliu | 321 | chao | liu |
| 3 | micro | 123 | bill | gates |
| 5 | helloworld | 123 | hello | world |
| 7 | ?? | 123 | ? | ? |
+----+------------+----------+------------+-----------+
4 rows in set (0.00 sec)
上网搜索之后,发现需要改一下charactor_set_results,改为utf8或者gb2312(要根据shell客户端设置的编码)
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 | /home/work/.jumbo/share/mysql/charsets/ | +--------------------------+-----------------------------------------+ 8 rows in set (0.00 sec) mysql> set character_set_results=utf8; Query OK, 0 rows affected (0.00 sec) 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 | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /home/work/.jumbo/share/mysql/charsets/ | +--------------------------+-----------------------------------------+ 8 rows in set (0.01 sec)
这时候,中文就可以正常查看了。
mysql> select * from user;
+----+------------+----------+------------+-----------+
| id | nickname | password | first_name | last_name |
+----+------------+----------+------------+-----------+
| 1 | chaoliu | 321 | chao | liu |
| 3 | micro | 123 | bill | gates |
| 5 | helloworld | 123 | hello | world |
| 7 | 你好 | 123 | 中 | 文 |
+----+------------+----------+------------+-----------+
4 rows in set (0.00 sec)
Mysql客户端中文乱码问题解决
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。