Can't get mysql2 gem to work with MAMP2 and RVM on Lion, Rails3 app

狂风中的少年 提交于 2019-11-30 14:34:31

I resolved this problem uninstalling mysql-connector-c and recompiling mysql2 gem with include and lib flags from brewed mysql server.

$ brew uninstall mysql-connector-c
$ gem uninstall mysql2
$ gem install mysql2 -- --with-mysql-include=/usr/local/Cellar/mysql/5.5.19/include --with-mysql-lib=/usr/local/Cellar/mysql/5.5.19/lib

http://abisso.org/2012/03/failed-to-allocate-memory/

You should not use MAMP for this.

I read what you are trying to do. Your problem is not the mysql2 gem. Your problem is your installation of mysql.

Follow this article showing using homebrew to install mysql. It is very simple and takes about 10-15 minutes including install time to get it setup.

http://blog.theablefew.com/very-simple-homebrew-mysql-and-rails

Side note with using brew to install mysql. After you install mysql and it succeeds it will spit out a ton of information, and you need to look at it carefully because there are 1-2 lines among all the other junk that are instructions, pasting some stuff, etc...

My Setup:

Currently in my setup i have MAMP (for my /sites directory) when doing simple stuff like wordpress sites, etc... Then i have my homebrew install of mysql for rails (eventually i switched to sqlite/pg for heroku). Yes, i can run them at the same time. I have this setup because my projects require me to jump around between rails apps, static html landing pages, and a few older php projects, and I like the separation having 2 mysql installs.

Max

Try adding this to your Gemfile:

gem 'mysql2', < '0.3'

I made a post about a similar problem a while back. You can view the answer here:

Cannot run migrations due to MySQL error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!