zoukankan      html  css  js  c++  java
  • 修改编码为utf8mb4 以支持emoji表情

    环境:

    项目db的所有字符集都已经初始化为utf-8,如 status命令显示如下:

    Server characterset: utf8
    Db characterset: utf8
    Client characterset: utf8
    Conn. characterset: utf8

    一、修改对应项目数据库级别字符集:

    mysql> show create database yyf;
    +----------+--------------------------------------------------------------+
    | Database | Create Database |
    +----------+--------------------------------------------------------------+
    | yyf | CREATE DATABASE `yyf` /*!40100 DEFAULT CHARACTER SET utf8 */ |
    +----------+--------------------------------------------------------------+
    1 row in set (0.00 sec)

    mysql> alter database yyf CHARACTER SET utf8mb4;
    Query OK, 1 row affected (0.00 sec)

    mysql> show create database yyf;
    +----------+-----------------------------------------------------------------+
    | Database | Create Database |
    +----------+-----------------------------------------------------------------+
    | yyf | CREATE DATABASE `yyf` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
    +----------+-----------------------------------------------------------------+
    1 row in set (0.00 sec)

    二、修改表级别的字符集:

     alter table t1 CHARSET=utf8mb4;

    三、修改客户端连接数据库的配置:

     return [
    'class' => 'yiidbConnection',
    'driverName' => 'mysql',
    'dsn' => 'mysql:host=xxxx;port=3306;dbname=yyf;',
    'username' => 'xxxx',
    'password' => 'xxxx',
    ###'charset' => 'utf8',
    'charset' => 'utf8mb4',
    ];
  • 相关阅读:
    Vue购物车项目
    总结前端面试过程中最容易出现的问题
    Node.js
    浏览器前端优化
    计算机课程
    谈谈对前端的理解
    MySQL
    阿里云Centos+Django+Nginx+uWSGI
    Windows + Apache + WSGI 部署Django
    Django积木块11 —— 缓存
  • 原文地址:https://www.cnblogs.com/yiyuf/p/4956699.html
Copyright © 2011-2022 走看看