Installing mysql2 gem for Ruby on Rails with Mac OSX 10.6

后端 未结 12 1119
悲哀的现实
悲哀的现实 2020-12-09 02:56

I am having a problem installing the mysql2 gem.

This comes up when I do gem install mysql2:

Marks-MacBook-Pro:~ Mark$ gem install mysql         


        
相关标签:
12条回答
  • 2020-12-09 03:18

    This command worked for me:

    gem install mysql2 -- --srcdir=/usr/local/mysql/include
    
    0 讨论(0)
  • 2020-12-09 03:18

    Make sure openssl is installed on Mac via Homebrew.

    brew install openssl
    
    Install mysql2 gem.
    
    gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/i
    
    0 讨论(0)
  • 2020-12-09 03:19

    The following worked for me

    brew install mysql 
    brew install mysql-connector-c
    gem install mysql2
    
    0 讨论(0)
  • 2020-12-09 03:21

    It seems that it cannot find the MySQL library. Have you installed MySQL?
    Try installing it via homebrew:

    brew install mysql
    

    or install it via macports or fink or whatever you prefer.

    Then try again with:

    gem install mysql2
    
    0 讨论(0)
  • 2020-12-09 03:22

    I don't need MySQL on Mac OS X, because I have MySQL installed on Vagrant box. Therefore, I just installed mysql-connector-c.

    brew install mysql-connector-c
    gem install mysql2
    
    0 讨论(0)
  • 2020-12-09 03:30

    You'll have to specify some additional environment variables to install this gem on the 64 bit architecture for Mac OSX 10.6:

    env ARCHFLAGS="-arch x86_64" gem install mysql2
    

    If you are using rvm you can add this as your default option in the ~/.rvmrc file:

    rvm_archflags="-arch x86_64"
    
    0 讨论(0)
提交回复
热议问题