Quick How-To for Grails with MySql

1. install mysql  (I’m running 5.0.83)
2. get java driver for mysql http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.10.zip/from/pick#mirrors

3. Open the zip file and extract the jar file into the lib directory of your Grails application.
4. alter the DataSource.groovy file in conf

import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration
dataSource {
    configClass = GrailsAnnotationConfiguration.class
    pooled = false
    driverClassName = "com.mysql.jdbc.Driver"
    username = "root"
    password = ""
    dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"

5. development {
        dataSource {
            dbCreate = "update" // one of ‘create’, ‘create-drop’,’update’
            //url = "jdbc:hsqldb:mem:devDB" //jdbc:hsqldb:file:devDB;shutdown=true
            url = "jdbc:mysql://"

6. create a catalog in mysql – ie. test    check your url, mine was
7. I ran grails console and then wrote some groovy/grom statements to test it  ie.  println Quote.count()


3 thoughts on “Quick How-To for Grails with MySql

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s