mysql - 在终端中安装 mysql gem 时出错

标签 mysql ruby

当我尝试在终端中运行以下命令时,收到一条错误,该错误阻止安装 mysql gem:

我跑:

sudo gem install mysql   

我收到以下错误:

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

如果您知道如何修复此错误并安装 mysql gem,请告诉我

最佳答案

安装 mysql2 gem 而不是 mysql 并确保在安装 gem 之前安装了 MySql:

brew install mysql
gem install mysql2

关于mysql - 在终端中安装 mysql gem 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27611927/

相关文章:

ruby-on-rails - Rails 4 + Devise : Invalid route name, 已在使用中

mysql - 我们可以在 MySQL 中创建嵌套数据库吗?如果是如何?

php - PHP、日期、MySQL 中的时区...?

ruby - ruby 的扩展语法是如何工作的?

ruby - 等同于 Ruby 中的 OCaml 变体

ruby - 通过管道执行 ruby​​ 脚本时 $stdin.gets 不起作用

ruby - 在不使用任何框架的情况下使用 Ruby 完成 Web 应用程序——有多难?陷阱?

mysql - 在控制台上运行相同的查询需要两次时间?

php - 如何修复我的代码以使用 php、mysql 在数组中保存 3 个值来进行调查?

mysql - 随机选择 3 行相等的次数