12 November, 2010
Datamapper, MySQL and Sinatra on OSX
Trying to set up Sinatra with Datamapper today, I was running into a lot of problems. I got errors when trying to install the mysql gem and the dm-mysql-adapter gem. When I actually managed to do it, Datamapper gave me the following error:
Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock'
I spent hours trying to fix it, but I finally suceeded. This is what worked for me:
- Uninstall Mysql on your computer (you also may need to do this)
- Uninstall the gems (sudo gem uninstall mysql, sudo gem uninstall dm-mysql-adapter)
- Download the latest mysql DMG from the MySQL website
- Install the gems (sudo gem install mysql, sudo gem install dm-mysql-adapter)
- Restart your computer
- Now do this to make the socket path work
That should hopefully make MySQL and Datamapper work. Connect like this in you app and you're good to go:
If you want to share or comment on this post, ping @runemadsen on Twitter