安装mysql2时出错:无法构建gem本机扩展 [英] Error installing mysql2: Failed to build gem native extension

查看:337
本文介绍了安装mysql2时出错:无法构建gem本机扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试为Rails安装 mysql2 gem时遇到了一些问题。当我尝试通过运行 bundle install gem install mysql2 来安装它时,它给我提供以下错误:

I am having some problems when trying to install mysql2 gem for Rails. When I try to install it by running bundle install or gem install mysql2 it gives me the following error:


安装mysql2时出错:错误:无法构建gem本机扩展。

Error installing mysql2: ERROR: Failed to build gem native extension.

如何解决这个问题并成功安装 mysql2

How can I fix this and successfully install mysql2?

推荐答案

sudo apt-get install libmysql-ruby libmysqlclient-dev

程序包 libmysql-ruby 已被停用并被替换由 ruby​​-mysql 这是我找到解决方案的地方。

Package libmysql-ruby has been phased out and replaced by ruby-mysql. This is where I found the solution.

如果上述命令不符合没有工作,因为找不到 libmysql-ruby ,以下内容应该足够了:

If the above command doesn't work because libmysql-ruby cannot be found, the following should be sufficient:

sudo apt-get install libmysqlclient-dev

在Red Hat / CentOS和其他发行版上,使用yum:

On Red Hat/CentOS and other distributions using yum:

sudo yum install mysql-devel

在Mac OS X上使用 Homebrew

On Mac OS X with Homebrew:

brew install mysql

这篇关于安装mysql2时出错:无法构建gem本机扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆