Using MySQL with Grails on Ubuntu
2009-11-23 07:58:40 | 0 Comment
As you see I did dive into [Grails](http://www.grails.org) and trying to have more and more knowledge about it since I am really interested in using it along with or instead of Ruby on Rails for my next two start-ups. Grails needs no configuration, it is just a full stack web framework which you can install and start creating projects. However if you are willing to use [MySQL](http://www.mysql.com) with your Grails project then you need to make some configurations that will not take even two minutes.
* Go ahead and do what it says in [here](https://help.ubuntu.com/community/JDBCAndMySQL).
* Download [MySQL JDBC Connector](http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.10.tar.gz/from/http://ftp.itu.edu.tr/Mirror/Mysql/).
* Extract the archive.
* Move the **mysql-connector-java-5.1.10-bin.jar** file to your **lib** folder.
After these steps there is only one configuration left for you to work with MySQL on Grails. Open your **config/DataSource.groovy** file.
* Change **driverClassName** to com.mysql.jdbc.Driver.
* Change the **url** to jdbc:mysql://localhost:3306/databaseName
That's all. You are all set. Enjoy Grails! :)
**Update: (June 20, 2011)**
Instead of copying mysql driver to the `/lib directory` of every project, you can add the downloaded jar to your classpath environment variable. Here is an example:
cd ~/devel
wget http://ftp.itu.edu.tr/Mirror/Mysql/Downloads/Connector-J/mysql-connector-java-5.1.16.tar.gz
tar xf mysql-connector-java-5.1.16.tar.gz
echo 'CLASSPATH=$CLASSPATH:/home/mengu/devel/mysql-connector-java-5.1.16/mysql-connector-java-5.1.16-bin.jar' >> ~/.bashrc
source ~/.bashrc
Check my latest project compector.com where you can post references about your former employers and see what others have said about the future employers. Sign up now and post a reference and share it on twitter or facebook.


Comments
Leave a Response