MySQL gem 安装问题

标签 mysql ruby-on-rails ruby rubygems

我对 MySQL gem 安装的错误感到有点困惑。由于 MySQL 从 5.0.xx 更新到 5.1.39,我已经卸载了 mysql gem,现在我无法正确安装它。

我已经下载了mysql-2.8.1.gem到服务器,因为它在代理后面。我阅读了很多教程,其中告诉我必须包含 mysql_config 才能消除此错误,但没有任何帮助。

操作系统是 Red Hat Enterprise Linux Server 5.3 (Tikanga)。

[my@server ~]$ sudo gem install mysql-2.8.1.gem --no-rdoc --no-ri -- --with-mysql-config=/usr/bin/mysql_config
Building native extensions.  This could take a while...
ERROR:  Error installing mysql-2.8.1.gem:
    ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile

make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H    -I/usr/include/mysql  -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC   -DUNIV_LINUX -DUNIV_LINUX -fPIC -g -O2   -c mysql.c
gcc -shared -o mysql_api.so mysql.o -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L.  -rdynamic -Wl,-export-dynamic    -rdynamic -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto  -lrt -ldl -lcrypt -lm   -lc
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -lmysqlclient
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [mysql_api.so] Error 1


Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

有什么建议吗?

最佳答案

从错误看来,您的 MySQL 版本与您使用的 gem 版本不兼容。

/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -lmysqlclient 
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient 
/usr/bin/ld: cannot find -lmysqlclient 

如果您安装了多个 MySQL 版本,则可能是 gem 正在使用旧版本。您应该使用 MySQL gem 文档来验证您正在使用的版本需要哪个版本的 MySQL。

关于MySQL gem 安装问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6423812/

相关文章:

ruby - 继续获取 "Could not find passenger (>=0) amongst"While Passenger

mysql - PDO - 从两个表中选择数据

mysql - 如何优化缓慢的 MySQL 表更新查询?

sql - 如何在 Rails 中编写以下查询?

ruby-on-rails - 如何在Rails中创建连接表记录,有很多: through relationship

ruby - 在 ruby​​ 中将 9999999999999999999999.001 转换为 "9999999999999999999999.001"

php - 如何使用第一个查询查询一个表并将行添加到另一个表? MySQL

MYSQL:如何使用多个标签进行选择

css - Twitter Bootstrap Extend 不工作

ruby - 如何使用 ruby​​ 将 unicode 添加到 ID3 标签?