简体   繁体   English

在rbenv上安装mysql gem

[英]installing mysql gem on rbenv

I'm trying to use vagrant on my MAC OSX machine. 我正在尝试在我的MAC OSX计算机上使用流浪汉。 I connected vagrant with using SSH and I set ruby 1.9.2-p290. 我使用SSH连接了流浪汉,并设置了ruby 1.9.2-p290。 Now I'm try to install ruby gems but I've been facing with this problem when I want to install mysql2 gem. 现在,我尝试安装ruby gems,但是当我想安装mysql2 gem时,我一直面临着这个问题。

Fetching: mysql-2.8.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

        /home/vagrant/.rbenv/versions/1.9.2-p290/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/vagrant/.rbenv/versions/1.9.2-p290/bin/ruby
    --with-mysql-config
    --without-mysql-config
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mlib
    --without-mlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-zlib
    --without-zlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-socketlib
    --without-socketlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-nsllib
    --without-nsllib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mygcclib
    --without-mygcclib
    --with-mysqlclientlib
    --without-mysqlclientlib


Gem files will remain installed in /home/vagrant/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.
Results logged to /home/vagrant/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

I set in Gem file 我在宝石文件中设置

gem 'mysql2'

and again I run bundle command but the result is the same. 再次运行bundle命令,但结果是相同的。

Why doesn't mysql run on vagrant? 为什么MySQL无法在无业游民上运行?

The mysql2 gem has native C extensions that build against mysql binaries. mysql2 gem具有针对mysql二进制文件构建的本机C扩展。 Your vagrant machine needs to have mysql installed. 您的无业游民的计算机需要安装mysql。 Do something like this 做这样的事情

$ vagrant ssh
$ sudo apt-get install mysql-server mysql-client

After mysql is installed, you should be able to install the mysql2 gem. 安装mysql之后,您应该能够安装mysql2 gem。

EDIT: you also need the mysql development libraries so 编辑:您还需要mysql开发库,因此

$ sudo apt-get install libmysqlclient-dev libmysqlclient16 ruby-dev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM