Springboot 运行flyway Unsupported character encoding 'utf8mb4'

在自己的springboot小项目中用到了flyway数据库版本迁移,使用如下sql建立数据库

create database db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

配置文件中配置了数据库连接信息

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/tendency_db?useUnicode=true&characterEncoding=utf8mb4&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=esns

然而运行时报错了

Caused by: org.flywaydb.core.internal.exception.FlywaySqlException: 
Unable to obtain connection from database: Unsupported character encoding 'utf8mb4'
-----------------------------------------------------------------------------------
SQL State  : S1009
Error Code : 0
Message    : Unsupported character encoding 'utf8mb4'

解决方案如下,将配置文件中的连接信息改为如下

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/tendency_db?useUnicode=true&character_set_server=utf8mb4&allowMultiQueries=true

你可能感兴趣的:(Springboot 运行flyway Unsupported character encoding 'utf8mb4')