MySQL Gem for Ruby On Rails

I searched everywhere, and not one of them solves my problem. I have created rails applications using SQLite, but not MySQL. For this particular project I need MySQL. When I try to load the server, I get an error message, so I try to install gems for MySQL and get another error. Does anyone have an understanding? Thanks!

rails server Could not find gem 'mysql2 (>= 0)' in any of the gem sources listed in your Gemfile. sudo gem install mysql2 Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/ext/mysql2/gem_make.out 
+1
source share
1 answer

I had this problem. You need to install gem mysql with native extensions.

The line you're probably looking for is this:

 $ ARCHFLAGS="-arch x86_64" gem install mysql2 --version '~> 0.2.7' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config 

Write full information about how this happens: http://softwaregravy.com/mysql-on-os-x-rails-3-0-7/

+3
source

All Articles