zoukankan      html  css  js  c++  java
  • mysql设置字符集CHARACTER SET

    在 my.cnf 配置文件中设置相关选项,改变为相应的character set。

    设置数据库编码(sudo vi /etc/mysql/my.cnf):

    [client]
    default-character-set = utf8
    
    [mysqld]
    character-set-server = utf8
    collation-server = utf8_general_ci

    查看设置结果

    更改my.cnf之前:

    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/local/mysql-5.6.21-linux-glibc2.5-x86_64/share/charsets/ |
    +--------------------------+---------------------------------------------------------------+

    设置之后,重启mysql服务($ sudo service mysql restart):

    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/local/mysql-5.6.21-linux-glibc2.5-x86_64/share/charsets/ |
    +--------------------------+---------------------------------------------------------------+
  • 相关阅读:
    mysql同步 小问题
    通过 XtraBackup 实现不停机不锁表搭建主从同步
    grep -A -B选项详解和mysqlbinlog
    MySQL存储过程中的3种循环
    mysql利用存储过程批量插入数据
    React routerV4 笔记
    数据结构算法基础定义
    网站性能优化
    去重除了indexOf的其他方法(使用对象Key的方法)及统计重复次数
    立即执行函数的两种写法及闭包
  • 原文地址:https://www.cnblogs.com/shaojiafeng/p/9791211.html
Copyright © 2011-2022 走看看