简体   繁体   English

在终端中安装mysql gem时出错

[英]Error while installing mysql gem in terminal

When I attempt to run the following in Terminal, I receive an error that prevents the installation of mysql gem: 当我尝试在终端中运行以下命令时,收到一个错误,阻止安装mysql gem:

I run: 我跑:

sudo gem install mysql   

I receive the following error: 我收到以下错误:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

/Users/(myuseraccount)/.rbenv/versions/2.1.5/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... no
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=/Users/(myuseraccount)/.rbenv/versions/2.1.5/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

extconf failed, exit code 1

Gem files will remain installed in /Users/(myuseraccount)/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/mysql-2.9.1 for inspection.
Results logged to /Users/(myuseraccount)/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-14/2.1.0-static/mysql-2.9.1/gem_make.out

Please tell me if you know how I can fix this error and install the mysql gem 请告诉我您是否知道如何解决此错误并安装mysql gem

bundle install 捆绑安装

Error was: 错误是:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. Gem :: Ext :: BuildError:错误:无法构建gem本机扩展。

.................. ..................

An error occurred while installing mysql2 (0.4.10), and Bundler cannot continue. 安装mysql2(0.4.10)时发生错误,并且Bundler无法继续。 Make sure that gem install mysql2 -v '0.4.10' succeeds before bundling. 捆绑之前,请确保gem install mysql2 -v '0.4.10'成功。

................... ...................

Solution was: 解决方案是:

gem update --system 宝石更新-系统

sudo apt-get install libmysqlclient-dev sudo apt-get安装libmysqlclient-dev

And then "bundle install" was OK. 然后“捆绑安装”就可以了。

Install mysql2 gem rather than mysql and be sure to have MySql installed before install the gem: 安装mysql2 gem而不是mysql并在安装gem之前确保已安装MySql:

brew install mysql
gem install mysql2

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

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