【gem安装】mysql2错误

错误信息

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/jaylin/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150423-6190-1ocfncu.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
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/jaylin/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
	--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-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 /home/jaylin/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.18 for inspection.
Results logged to /home/jaylin/.rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/mysql2-0.3.18/gem_make.out
An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling.

解决方案:

sudo apt-get install libmysqlclient-dev


转载于:https://my.oschina.net/jaylin/blog/405453

### 解决 `yum install mysql` 失败的方法 当通过 `yum` 安装 MySQL 遇到失败时,可以尝试以下方法来解决问题。 #### 方法一:更新软件包列表并重新安装 有时错误可能是由于本地缓存中的元数据过期引起。因此建议先刷新 `yum` 软件仓库的信息再重试安装命令: ```bash sudo yum clean all sudo yum update -y sudo yum -y install mysql-server ``` 如果上述操作仍无法成功,则可能是因为默认的 CentOS 库里不再提供旧版本的 MySQL 或者存在依赖关系冲突等问题[^1]。 #### 方法二:添加额外的 YUM 源 对于某些特定情况下的安装问题,可以通过增加 EPEL(Extra Packages for Enterprise Linux)或其他第三方源来获取更多资源支持。例如,在 CentOS 上设置 MHA 架构前就需要下载相应的 RPM 文件[^4]。 执行如下指令以启用 EPEL 并再次尝试安装 MySQL: ```bash sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm sudo yum repolist sudo yum -y install mysql-community-server ``` #### 方法三:手动编译环境准备 针对更复杂的情形,比如开发环境中需要定制化构建的话,可按照下面步骤准备好必要的工具链之后再来处理数据库服务端组件的部署工作[^3]: ```bash sudo yum -y groupinstall "Development Tools" sudo yum -y install gcc mysql-devel ruby-devel rubygems gem install mysql -- --with-mysql-config=/usr/bin/mysql_config ``` 以上三种方案涵盖了不同场景下可能出现的情况及其对应的解决方案。具体采取哪种方式取决于实际遇到的具体报错提示以及操作系统本身的配置状况等因素影响。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值