How to install MySQL gem on Mac OS X

前端 未结 10 1223
情歌与酒
情歌与酒 2020-12-29 12:30

What do I need to install mysql gem on Mac OS X ? I\'m getting error \"failed to build native extensions\".

相关标签:
10条回答
  • 2020-12-29 13:00

    I install MySQL with DWG mysql_config will be located at /usr/local/mysql/bin/mysql_config

    gem install mysql -- \ --with mysql-config=/usr/local/mysql/bin/mysql_config 
    
    0 讨论(0)
  • 2020-12-29 13:01

    Some time back I wrote some instructions on my blog on how to do it in 10.6, but I think it's the same in 10.5.

    I comes down to this command:

    ARCHFLAGS="-arch x86_64" gem install mysql -- \
      --with-mysql-config=/path/to/mysql_config
    

    but you need to find the real value for /path/to/mysql_config. My blog post has a few tips, but there's one very important thing: you must have installed MySQL with headers. The official .pkg installer from MySQL doesn't IIRC. The best thing to do is to install MySQL with Homebrew (in the post I use examples from a MacPorts install, but that's because Homebrew wasn't mature when I wrote it).

    If you install MySQL with Homebrew mysql_config will be located at /usr/local/bin/mysql_config and if you install it with MacPorts it will be at /opt/local/lib/mysql5/bin/mysql_config.

    I concur with the other answer that suggest that you install the mysql2 gem instead of mysql. I think the command above should work for mysql2 too.

    0 讨论(0)
  • 2020-12-29 13:03

    I'm using Mac OS X 10.10 (Yosemite), and to me worked with the command bellow:

    gem install mysql2 -- \ --with-mysql-config=/usr/local/mysql/bin/mysql_config
    
    0 讨论(0)
  • 2020-12-29 13:04

    I came across this issue while setting up MySQL gem on MacOs Mojave .This worked for me

    1 Ensure Xcode command line tools are installed. xcode-select --install

    1. For me the build was still failing with some header files missing which you have to install open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

    This link pointed to right direction. Can't compile C program on a Mac after upgrade to Mojave

    0 讨论(0)
  • 2020-12-29 13:08

    I'm running Mac OS X Lion with Homebrew.

    The correct command to install a ruby gem is…

    gem install mysql -- \ --with-mysql-config=/usr/local/bin/mysql_config 
    
    0 讨论(0)
  • 2020-12-29 13:08

    For me it did the most easy:

    brew install mysql
    gem install mysql
    

    Brew is a package manager for Mac OS, a must have. Using it to install mysql first brings everything that the gem command is missing.

    0 讨论(0)
提交回复
热议问题