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

    查看字符编码

    1 show variables like "%char%"

    字符编码

    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/src/mysql-5.7.22-linux-glibc2.12-x86_64/share/charsets/ |
    +--------------------------+--------------------------------------------------------------+
    8 rows in set (0.00 sec)                

    修改字符编码

    临时修改
    set character_set_server=utf8
    永久修改
    vim /etc/my.conf
    cat /etc/my.conf
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    character_set_server=utf8          添加的数据
    # Settings user and group are ignored when systemd is used.
    # If you need to run mysqld under a different user or group,
    # customize your systemd unit file for mariadb according to the
    # instructions in http://fedoraproject.org/wiki/Systemd
    
    [mysqld_safe]
    log-error=/var/log/mariadb/mariadb.log
    pid-file=/var/run/mariadb/mariadb.pid
    
    #
    # include all files from the config directory
    #
    !includedir /etc/my.cnf.d

    查看表使用的字符编码格式

    show create table 表名

    修改表使用的字符编码格式

    alter table name default character set latin 1

    常见字符编码

    ASCLL       英文 
    GB2312      中文
    GBK        中文
    UTF-8       万国字符集
    UTF-16      万国字符集
  • 相关阅读:
    ubuntu安装Sogou输入法失败
    二进制转换与此平台上的长模式不兼容
    thinkpad e570 如何进入bios
    计算beta分布并画图(1)
    python利用pandas和xlrd读取excel,特征筛选列
    python利用jieba进行中文分词去停用词
    python利用heapq实现小顶堆(查找最大的N个元素)
    python根据索引删除内容并写入文本
    [Water]UVA 11792 Commando War
    [最大子序列和]Hdu 5280 Senior's Array
  • 原文地址:https://www.cnblogs.com/bnre/p/14148548.html
Copyright © 2011-2022 走看看