環境:mysql
項目db的全部字符集都已經初始化爲utf-8,如 status命令顯示以下:sql
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8數據庫
1、修改對應項目數據庫級別字符集:yii
mysql> show create database yyf;
+----------+--------------------------------------------------------------+
| Database | Create Database |
+----------+--------------------------------------------------------------+
| yyf | CREATE DATABASE `yyf` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+--------------------------------------------------------------+
1 row in set (0.00 sec)spa
mysql> alter database yyf CHARACTER SET utf8mb4;
Query OK, 1 row affected (0.00 sec)utf-8
mysql> show create database yyf;
+----------+-----------------------------------------------------------------+
| Database | Create Database |
+----------+-----------------------------------------------------------------+
| yyf | CREATE DATABASE `yyf` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+-----------------------------------------------------------------+
1 row in set (0.00 sec)io
2、修改表級別的字符集:table
alter table t1 CHARSET=utf8mb4;class
3、修改客戶端鏈接數據庫的配置:配置