无法在 Linux (CentOS) 上安装 "mysql2" gem

Unable to install "mysql2" gem on Linux (CentOS)

我无法在我的 CentOS linux 机器上安装 "mysql2" gem。

我最近按照以下教程安装了 mysql:http://www.rackspace.com/knowledge_center/article/installing-mysql-server-on-centos

当我尝试下载 "mysql2" gem 时,我得到以下日志:

[root@vc2cmmka035538n ruby]# gem install mysql2
ERROR:  Could not find a valid gem 'mysql2' (>= 0) in any repository
ERROR:  Possible alternatives: mysql

环境信息:

来自他们的 github 页面,引用

This gem links against MySQL's libmysqlclient C shared library. You may need to install a package such as libmysqlclient-dev, mysql-devel, or other appropriate package for your system.

所以,您可能想先安装这些软件包。然后,如果您仍然遇到问题,您甚至可以手动编译 gem。 https://github.com/brianmario/mysql2

如果 mysql repo 在您的系统上被禁用,这里是 link 关于安装它们的

http://dev.mysql.com/doc/mysql-repo-excerpt/5.6/en/linux-installation-yum-repo.html