zoukankan      html  css  js  c++  java
  • 数据库修改为utf8mb4

    1、查看数据库的编码格式  SHOW VARIABLES Like '%char%'

     2、修改配置文件my.cnf ,把下面有utf8的都改为utf8mb4

    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
    
    [mysqld]
    #
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    #
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
    #
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
    [client]
    default-character-set=utf8mb4
    
    [mysql]
    default-character-set=utf8mb4
    
    [mysqld]
    log-bin=mysql-bin 
    binlog-format=ROW 
    server_id=1 
    max_connections=1000
    
    init_connect='SET collation_connection = utf8mb4_unicode_ci'
    init_connect='SET NAMES utf8mb4'
    character-set-server=utf8mb4
    collation-server=utf8mb4_unicode_ci
    skip-character-set-client-handshake

    3、重启数据库

    查看编码:

    4、改数据库编码和表编码

    alter database <数据库名> character set utf8mb4;

    alter table  <表名>    CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; 

    5、查看数据表的编码格式

    show create table <表名>;

  • 相关阅读:
    gitlab 建仓的流程
    gitlab安装
    以普通用户登录 su root 用vncviewer:xxxxx 会报错!!exit 回到最初环境变的用户 问题解决!!!!
    linux下绘图工具dia
    rds材资收集
    export 解决环境变量的问题!!!!
    查看nginx版本号
    grep -C n "匹配字符串" 匹配字符串上下N行
    查看TOMCAT的版本
    导出数据库的结构不含数据
  • 原文地址:https://www.cnblogs.com/javabg/p/13529364.html
Copyright © 2011-2022 走看看