Error installing mysql2: Failed to build gem native extension(安装 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
?
推荐答案
在 Ubuntu/Debian 和其他使用 aptitude 的发行版上:
On Ubuntu/Debian and other distributions using aptitude:
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
在带有 Homebrew 的 Mac OS X 上:
On Mac OS X with Homebrew:
brew install mysql
这篇关于安装 mysql2 时出错:无法构建 gem 原生扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:安装 mysql2 时出错:无法构建 gem 原生扩展


基础教程推荐
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01