Using MySQL instead of in-memory database for a Grails application
- 4 oktober, 2010 -
- Groovy and Grails, Programming -
- Tags : database, grails, java, mysql
- 0 Comments
A Grails application by default uses a in-memory HSQL database. To switch to a MySQL database the steps are simple and straightforward.
* Download the MySQL JDBC driver [called a connector] from the [MySQL website][1]
* Extract the zip or tar archive
* Copy the driver (at this time of writing called `mysql-connector-java-5.1.13-bin.jar` into the `grails-app/lib` directory
* Configure your application datasource in file ‘grails-app/conf/DataSource.groovy’
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://localhost/"
driverClassName = "com.mysql.jdbc.Driver"
port = // default 3306
username = ""
password = " "
}
}
Use your own database settings!
* Start your Grails application
[1]: http://dev.mysql.com/downloads/connector/j/