• mysql5.7设置默认编码


    1、通过 show variables like '%char%';查看MySQL字符集情况

    mysql> show variables like '%char%';
    +--------------------------+----------------------------+
    | 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/ |
    +--------------------------+----------------------------+

    2、修改mysql配置文件

    #备份配置文件
    sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf_2
    sudo vim  /etc/mysql/mysql.conf.d/mysqld.cnf
    # 修改处1:添加以下2行
    [client]
    default-character-set=utf8

    [mysqld]
    # 修改处2:添加以下3行
    default-storage-engine=INNODB
    character-set-server=utf8
    collation-server=utf8_general_ci

    3、重启mysql
    service mysql restart

    4、查看字符集
    mysql -uroot -p

    mysql> show variables like "%char%";
    +--------------------------+----------------------------+
    | Variable_name | Value |
    +--------------------------+----------------------------+
    | character_set_client | utf8 |
    | character_set_connection | utf8 |
    | character_set_database | utf8 |
    | character_set_filesystem | binary |
    | character_set_results | utf8 |
    | character_set_server | utf8 |
    | character_set_system | utf8 |
    | character_sets_dir | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+


    ---------------------
    作者:zheng_lan_fang
    来源:CSDN
    原文:https://blog.csdn.net/zheng_lan_fang/article/details/77941232
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    面向对象定义
    xml与面上对象初识
    模块configparser/subprocess/表格处理模块
    python模块
    python-判断语句
    python了解
    Qt Qwdget 汽车仪表知识点拆解7 图像绘制,旋转
    Qt Qwdget 汽车仪表知识点拆解6 自定义控件
    Qt Qwdget 汽车仪表知识点拆解5 标题栏图标闪烁
    Qt Qwdget 汽车仪表知识点拆解4 另类进度条实现
  • 原文地址:https://www.cnblogs.com/allexw/p/10385962.html
Copyright © 2020-2023  润新知