P65 H2切换Mysql 搭建MySql

需求:以前使用H2数据库,是为了让大家快速上手,现在部署在线上,需要使用Mysql

将H2的依赖全部换为mysql

在这里插入图片描述
我本地数据库版本是mysql5.5,flyway执行脚时报错:

[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:6.1.4:migrate (default-cli) on project community: org.flywaydb.core.internal.li
cense.FlywayEditionUpgradeRequiredException: Flyway Enterprise Edition or MySQL upgrade required: MySQL 5.5 is no longer supported by Flyway Co
mmunity Edition, but still supported by Flyway Enterprise Edition. -> [Help 1]

flyway 不支持mysql5.5社区版了,因为考虑windows重装MySql比较麻烦,于是我就想在远程服务器上安装一个5.5以上的数据库。
虽然idea引入的版本是5.1,不要管
我安装了一个5.7的数据库

Linux下安装mysql完整教程

数据库安装完成以后,端口号开放,远程连接数据库依然出错

1130, "Host 'xxxx' is not allowed to connect to this MySQL server"

解决方法:参考这篇blog

此时数据库连接上了,回到项目,执行数据库脚本:提示table不存在

 DB: Table 'community.COMMENT' doesn't exist (SQL State: 42S02 - Error Code: 1146)

分析原因:应为Mysql在linux上,是严格区分大小写的,windows一般不区分大小写。于是将数据库脚本全部改为小写(Ctrl+Shit+U),执行过程中又出现了语法错误:
H2与Mysql的更改语句是有区别的

H2的写法

alter table QUESTION alter column ID Bigint auto_increment;

Mysql的写法( alter column 替换为 modify)

alter table QUESTION modify ID Bigint auto_increment;

运行项目依然有错,修改Mysql配置文件,让大小写不敏感

Linux下MySQL大小写敏感问题

记得mvn flyway:repair修复错误的文件

发布了199 篇原创文章 · 获赞 6 · 访问量 9001

猜你喜欢

转载自blog.csdn.net/shujuku____/article/details/104965634