Setting-up MAMP for Php & Ruby on Rails with MySQL

If you want to develop php on localhost with you Mac, you sould use MAMP. But it doesn’t display error. To change that, just go in bin/php/php5.6.2/conf/php.ini and change display_errors = “Off” by “On”. Easy, but if we don’t know it could take time.

Now if you want to use Ruby on Rails on MAMP with MySQL instead of SQLite you need to download and install MAMP’s libraries.
After that, you should install Mysql for Ruby using Gem, do the command line in your terminal :

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

And finally, you will have “gem installed”. To create a new Rails’s project with MySQL :  rails -d mysql myProject. Next open the file config/database.yml and add the line : socket: /Applications/MAMP/tmp/mysql/mysql.sock below host.
Don’t forget to put your password !

Now you can start working 😉

2 thoughts on “Setting-up MAMP for Php & Ruby on Rails with MySQL

  1. I tried your instructions but I’m still getting this error:

    $ rake db:migrate
    (in /Users/rahilSites/test)
    rake aborted!
    uninitialized constant MysqlCompat::MysqlRes

    (See full trace by running task with –trace)

Leave a Reply

Your email address will not be published. Required fields are marked *