Error installing mysql2: Failed to build gem native extension

后端 未结 27 2686
清酒与你
清酒与你 2020-11-22 08:06

I am having some problems when trying to install mysql2 gem for Rails. When I try to install it by running bundle install or gem install mysq

相关标签:
27条回答
  • 2020-11-22 08:57

    For MacOS Mojave:

    gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include

    0 讨论(0)
  • 2020-11-22 08:57

    Solution only works on Mac OS X

    If you've installed MySQL with homebrew, what worked for me was uninstalling MySQL, and installing MySQL Community Edition via the MySQL website (https://www.mysql.com/).

    After installed, just re-enter the command to gem install mysql2 or if necessary, sudo gem install mysql2, if you are getting permission denied problems.

    0 讨论(0)
  • 2020-11-22 09:01

    Another way for MacOS users

    If you used "brew" to install mysql:

    gem install mysql2 -v 'x.x.x' -- --with-mysql-config=/usr/local/Cellar/mysql/y.y.y/bin/mysql_config
    

    x.x.x = version of the mysql2 gem you want to install
    y.y.y = the version of mysql you have installed ls /usr/local/Cellar/mysql to find it.

    0 讨论(0)
  • 2020-11-22 09:02

    download the right version of mysqllib.dll then copy it to ruby bin really works for me. Follow this link plases mysql2 gem compiled for wrong mysql client library

    0 讨论(0)
  • 2020-11-22 09:04

    I have several computers, 32 and 64 bits processor, they run on Ubuntu Linux, Maverick (10.10) release.

    I had the same problem, and for me, the sudo apt-get install libmysql-ruby libmysqlclient-dev did the job!!!

    0 讨论(0)
  • 2020-11-22 09:05

    If still getting error then follow the steps of mysql2 gem installation on Rails 3 on -

    http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html

    where most of the user were able to install mysql2 gem.

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