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

标签 mysql grails

我可以针对内置内存数据库运行我的 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.6 Windows 服务器。

最佳答案

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

dialect = org.hibernate.dialect.MySQL5InnoDBDialect

而不是:

dialect = org.hibernate.dialect.MySQLInnoDBDialect

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

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

相关文章:

grails - Gant构建脚本,如何检索我要执行的任务

ajax - Grails 形式远程

grails - 无法在grails中调用方法本身

php - 将查询结果放入数组然后内爆?

mysql - MySQL 是否有允许 "WHERE x = NULL"(意思是 "WHERE x IS NULL")的 SQL 模式?

grails - Groovy 脚本向 Grails Web App 发送多部分请求以进行测试

java - Java 中的动态查找器?

mysql - 基于带有子选择的 where 语句更新 mysql 中的列

php - SQL更新大量行

php - PDOStatement->在生产服务器上执行比在开发服务器上慢 14 倍