gpt4 book ai didi

mysql - Grails:无法在 mysql 上创建表

转载 作者:行者123 更新时间:2023-11-29 08:04:26 25 4
gpt4 key购买 nike

我可以针对内置内存数据库运行我的 grails 应用程序,但是当我尝试让它与 MYSQL 一起使用时,它总是无法创建架构并出现以下错误。

2014-04-11 16:05:16,445 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport  - Unsuccessful: create table registration_code (id bigint not null auto_increment, date_created datetime not null, token varchar(255) not null, username varchar(255) not null, primary key (id)) type=InnoDB 
2014-04-11 16:05:16,448 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 1
2014-04-11 16:05:16,449 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Unsuccessful: create table report (id bigint not null auto_increment, version bigint not null, category varchar(255) not null, description longtext not null, name varchar(255) not null unique, reportsql longtext not null, views integer not null, primary key (id)) type=InnoDB

这个错误几乎没有告诉我任何信息。

可能是由于某种原因,它试图针对他内置的内存数据库创建一个 mysql 模式。

registration_code 表可能是我安装的 spring security 模块的一部分。我可以手动创建的“报告”表,它不包含保留字或类似内容。

在mysql中,我创建了一个与应用程序同名的数据库(我猜我必须这样做)。我使用的用户对所有内容以及创建的数据库都具有全局权限。

有什么办法可以调试吗?例如有什么方法可以查看 SQL grails 正在尝试使用什么?

我尝试将所有未保留的域对象和字段称为(例如 secRoles 而不是角色)

我的 datasource.groovy 看起来像这样:

dataSource {
dialect = org.hibernate.dialect.MySQLInnoDBDialect
pooled = true
jmxExport = true
driverClassName = "com.mysql.jdbc.Driver"
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
environments {
development {
dataSource {
dbCreate = "create"
username = "myuser"
password = "mypass"
url = 'jdbc:mysql://localhost/'
}
mysql 5.6 chalice 2.3.6Windows 服务器。

最佳答案

好的,解决方案是这样的:

dialect = org.hibernate.dialect.MySQL5InnoDBDialect

而不是:

dialect = org.hibernate.dialect.MySQLInnoDBDialect

遗憾的是,grails 在默认的conf 文件中没有提供示例mysql 连接。

关于mysql - Grails:无法在 mysql 上创建表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23016719/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com