SUBJ: as usually, couldnt find an easy tutorial, so im making one.
- Install XAMPP, launch it.
- Check the mysql config > my.ini. Remember the user, password and port.
- In your grails BuildConfig.groovy add this line:
dependencies {
...
runtime 'mysql:mysql-connector-java:5.1.34'
...
}
...
- In your DataSource.groovy comment the defaule values and add your own:
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "username from the config file"
password = "password from the config file"
- There are the environment specific settings. The dbCreate = 'create' means that a new DB is created each time you run the app. Change it to 'update' and the DB will be persisted and updated each time.
url = "jdbc:mysql://localhost:PORT_FROM_CONFIG_FILE_HERE/dev_db"
Change the url to the DB schema. Not that you have to create it first in your DB. (I used MySQL workbench to connect to a running XAMPP DB, and created a schema)
- Basically that is it, now your app in development mode (or the mode you edited in the environment settings) will use the database you specified. Just remember that you must start the Apache too in XAMPP.
- Oh, and you possibly need to grant permission for the user you defined, it is done through XAMPP mysql admin button.
No comments:
Post a Comment