在Linux上安装mysql2 Gem时出现错误
时间:2019-05-19 01:26:01 来源:igfitidea点击:
错误:
在Linux系统上安装MySQL gem时,我遇到了以下问题。
# gem install mysql2 -v '0.3.18'
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
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.
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/mysql2-0.3.18 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-linux/2.1.0/mysql2-0.3.18/gem_make.out
解决方案:
为了解决这个问题,我们需要在Linux系统上安装MySQL开发和客户端包。
在Ubuntu和Debian:
$ sudo apt-get install libmysqlclient-dev
在Redhat & CentOS:
# yum install mysql-devel
在Mac OS X上:
$ brew install mysql

