1

I have searched everywhere and no ones solutions solve my problem. I have built rails apps using SQLite but not MySQL. For this particular project, I need MySQL. When I attempt to boot the server I get an error, so I attempt to install the gems for MySQL and get another error. Does anyone have any insight? Thank you!

    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
6
  • It looks like you are running OSX... which version? Have you installed the development tools (Xcode) for your version of OSX? Commented Apr 15, 2011 at 21:16
  • How did you install mysql on your os x machine? Commented Apr 15, 2011 at 21:37
  • OS X should already have MySQL installed... but you can also download binaries from the MySQL website. Commented Apr 15, 2011 at 21:53
  • Running 10.6.6. I'm trying to use MAMP as MySQL server, but I believe I have MySQL installed directly from the binary. Commented Apr 15, 2011 at 22:05
  • reinstalled server via binary but now get this: dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle Expected in: flat namespace dyld: Symbol not found: _mysql_get_client_info Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle Expected in: flat namespace Trace/BPT trap Commented Apr 15, 2011 at 22:13

1 Answer 1

3

I had this problem. You need to install the mysql gem 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 

Full write up on getting it going here: http://softwaregravy.com/mysql-on-os-x-rails-3-0-7/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.