zoukankan      html  css  js  c++  java
  • Mysql客户端中文乱码问题解决

    另一篇一样的:http://www.cnblogs.com/charlesblc/p/5939399.html

    用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)
  • 相关阅读:
    线程池知识点详解
    redis实现用户登录
    php导出csv文件
    thinkphp5 内置接口开发与使用
    checkbox选择框
    简单权限管理开发设计 php
    ThinkPHP接入log4php日志监控系统
    mysql查询优化
    PHP读写文件高并发处理实例-转
    进程、线程、同步、异步
  • 原文地址:https://www.cnblogs.com/charlesblc/p/5973488.html
Copyright © 2011-2022 走看看