zoukankan      html  css  js  c++  java
  • MySQL修改字符集编码

    通过修改字符集编码为utf8,彻底解决中文问题。

    一. 登录MySQL查看SHOW VARIABLES LIKE ‘character%’;下字符集,显示如下:

    +--------------------------+----------------------------+
    | 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的my.cnf文件中的字符集键值

    [client]
    default-character-set=utf8
    [mysql]
    default-character-set=utf8
    [mysqld]
    collation-server = utf8_unicode_ci
    init-connect=’SET NAMES utf8′
    character-set-server = utf8
    

    或者直接命令行修改:

    SET character_set_client = utf8;
    SET character_set_results = utf8;
    SET character_set_connection = utf8;
    

    重启mysql服务即可。

    注意:命令行修改只对当前状态有效,重启失效。彻底解决请修改文件。


    参考###

  • 相关阅读:
    补码原理
    清风徐来,水波不兴
    月尾和周尾
    又一春又一季
    9.11
    晨光无限
    9.18
    心悠
    小事一桩
    一周岁啦
  • 原文地址:https://www.cnblogs.com/nju2014/p/5369899.html
Copyright © 2011-2022 走看看