Ok. I solved it. Had to recompile gem mysql Didn't come up that easy. First I had to go to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 and run sudo ruby extconf.rb --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config manually from there. That made a proper Makefile And only after that sudo gem install mysql started to work. Mysql5