mysql修改编码支持utf8mb4

mysql修改编码支持utf8mb4

utf8mb4支持

如果要支持特殊表情就必须支持utf8mb4

修改配置文件my.cnf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
character-set-client-handshake=FALSE
character-set-server=utf8mb4
#collation-server=utf8mb4_general_ci
collation-server=utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'

查看数据库编码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
use mysql;
show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+