[英]Grails: cant create tables on mysql
我可以对内置的内存数据库运行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
这个错误告诉我几乎什么都没有。
可能是由于某种原因,它试图针对他内置的内存DB创建mysql模式。
registration_code表大概是我安装的spring安全模块的一部分。 我可以手动创建的“报告”表,其中不包含保留字或类似字词。
在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 grails 2.3.6 Windows服务器。
好的,解决方案是这样的:
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
而不是:
dialect = org.hibernate.dialect.MySQLInnoDBDialect
在默认的conf文件中,没有附带示例mysql连接的grails遗憾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.