包说明html
mysql-connector-java-5.1.45.jarjava
MySQL:5.5.28mysql
emoji: 🎽 👖 👘 👙 💼 👜 👝 👛spring
JSON: \uD83C\uDFBD \uD83D\uDC56 \uD83D\uDC58 \uD83D\uDC59 \uD83D\uDCBC \uD83D\uDC5C \uD83D\uDC5D \uD83D\uDC5Bsql
数据库:? ? ? ? ? ? ? ?数据库
数据库字符集、表等字符集:utf8mb4_unicode_ci、utf8mb4tomcat
网上的一大堆,没说到核心点上,官方文档以下。https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-charsets.html服务器
For Connector/J 5.1.46 and earlier: In order to use the utf8mb4
character set for the connection, the server MUST be configured with character_set_server=utf8mb4
; if that is not the case, when UTF-8
is used for characterEncoding
in the connection string, it will map to the MySQL character set name utf8
, which is an alias for utf8mb3
.url
5.1.46早期版本,若是要支持 utf8mb4,MySQL Server服务器端必须修改 my.ini 配置文件spa
[mysqld]
character-set-server=utf8mb4
5.1.47之后版本,utf-8 映射为 utf8mb4,不想修改服务器,就升级下驱动,并设置下链接字符串
spring.datasource.url=jdbc:mysql://localhost:3306/db?characterEncoding=UTF-8
说明
不须要设置 spring.datasource.tomcat.init-s-q-l=SET NAMES utf8mb4,也不清楚事务里面支不支持,并很差使
数据库链接字符串,character_set_server=utf8mb4,试了没用