Phone character storage problem mysql

1. The table has been built also be converted into utf8mb4

命令:ALTER TABLE `TABLE_NAME` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; (将TABLE_NAME替换成你的表名)

2. Modify the required fields utf8mb4

ALTER TABLE app_message MODIFY title  VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '标题';

3. Modify the mysql configuration: vim /etc/my.cnf

init-connect='SET NAMES utf8mb4'
character-set-server=utf8mb4

4. Restart mysql

service mysqld restart

Reproduced in: https: //my.oschina.net/funcy/blog/1634935

Guess you like

Origin blog.csdn.net/weixin_33750452/article/details/91658509