• (转)CentOS 7下MySQL5.6的修改字符集编码为UTF8(解决中文乱码问题)


    【From:】http://www.2cto.com/database/201311/255324.html
     
    一、登录MySQL查看用SHOW VARIABLES LIKE ‘character%’;下字符集,显示如下:
     
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    +--------------------------+----------------------------+
    | Variable_name | Value |
    +--------------------------+----------------------------+
    | character_set_client | utf8 |
    | character_set_connection | utf8 |
    | character_set_database | latin1 |
    | character_set_filesystem |binary|
    | character_set_results | utf8 |
    | character_set_server | latin1 |
    | character_set_system | utf8 |
    | character_sets_dir | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    character_set_database和character_set_server的默认字符集还是latin1。
     
    二、最简单的完美修改方法,修改mysql的 /etc/my.cnf 文件中的字符集键值(注意配置的字段细节):
     
    [plain] view plain copy
     
    1. 1、在[mysqld]字段里加入character-set-server=utf8,如下:  
    2.    
    3. [mysqld]  
    4. port = 3306  
    5. socket = /var/lib/mysql/mysql.sock  
    6. character-set-server=utf8  
    7.    
    修改完成后,sudo systemctl restart mysqld重启mysql服务就生效。
     
    使用SHOW VARIABLES LIKE ‘character%’;查看,发现数据库编码全已改成utf8。
    [sql] view plain copy
     
    1. +--------------------------+----------------------------+  
    2. | Variable_name | Value |  
    3. +--------------------------+----------------------------+  
    4. | character_set_client | utf8 |  
    5. | character_set_connection | utf8 |  
    6. | character_set_database | utf8 |  
    7. | character_set_filesystem | binary |  
    8. | character_set_results | utf8 |  
    9. | character_set_server | utf8 |  
    10. | character_set_system | utf8 |  
    11. | character_sets_dir | /usr/share/mysql/charsets/ |  
    12. +--------------------------+----------------------------+  

     

  • 相关阅读:
    基于mybatis的crud demo
    事务的隔离级别
    spring中ioc的实现
    spring中xml配置文件
    spring中AOP的实现
    mybatis框架
    基于Mapreduce的并行Dijkstra算法执行过程分析
    算法技巧:位运算 逻辑运算
    day04_09 while循环03
    day04_08 while循环02
  • 原文地址:https://www.cnblogs.com/zhongshenggen/p/6211679.html
Copyright © 2020-2023  润新知