Grails:无法在mysql上创建表 [英] Grails: cant create tables on mysql

查看:106
本文介绍了Grails:无法在mysql上创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以针对内置的内存数据库运行grails应用程序,但是当我尝试使其与MYSQL一起使用时,它始终无法创建具有以下错误的架构.

I can run my grails app against the built in memory DB, but when I try to get it to work with MYSQL, it always fails to create the schema with the below error.

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

这个错误告诉我几乎什么都没有.

This error tells me almost nothing.

由于某种原因,它可能试图针对他内置的内存DB创建mysql模式.

It could be that its trying to create a mysql schema against he built in memory DB for some reason.

registration_code表大概是我已安装的spring安全模块的一部分. 我可以手动创建的报告"表,其中不包含保留字或类似字词.

the registration_code table is presumably part of spring security module I have installed. the "report" table I can create by hand, it contains no reserved words or similar.

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

In mysql, I created a database with the same name as the application (I am guessing I have to do this). The user I'm using has global permissions on everything, and the created db.

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

Is there any way to debug this? e.g. any way to see what SQL grails is trying to use?

我尝试调用我所有的域对象和字段中未保留的内容(例如secRoles而不是角色)

I have tried to call all my domain objects and fields things which are not reserved (e.g. secRoles instead of roles)

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

My datasource.groovy looks like this:

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服务器.

mysql 5.6 grails 2.3.6 Windows server.

推荐答案

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

OK, the solutions is this:

dialect = org.hibernate.dialect.MySQL5InnoDBDialect

而不是:

dialect = org.hibernate.dialect.MySQLInnoDBDialect

可惜的是,默认conf文件中没有示例mysql连接.

Shame that grails does not come with an example mysql connection in the default conf file.

这篇关于Grails:无法在mysql上创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆