• 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
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    Nginx文件下载服务器部署
    Git分支命名规范
    ROS通信介绍
    linux环境设置默认路由的优先级
    Python日志方案
    Python threading Local()函数用法:返回线程局部变量
    Python中websocket的使用示例
    MQTT的Python使用示例
    利用systemback打包个人ISO系统镜像
    Spring Security学习笔记三
  • 原文地址:https://www.cnblogs.com/allexw/p/10385962.html
Copyright © 2020-2023  润新知