简体   繁体   English

尝试了许多建议,如何安装mysql2 gem?

[英]Tried many suggestions, how do I install mysql2 gem?

I'm trying to install a mysql2 gem on a ruby on rails app. 我正在尝试在Rails应用程序的红宝石上安装mysql2 gem。 I'm currently running Ubuntu 11.04 and this is the error I get when I run sudo gem install mysql2 or bundle install : 我当前正在运行Ubuntu 11.04,这是我运行sudo gem install mysql2bundle install时遇到的错误:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile

make
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H    -I/usr/include/mysql -DBIG_JOINS=1  -fno-strict-aliasing  -g -fPIC -fno-strict-aliasing -g -g -O2  -fPIC  -Wall -funroll-loops  -c client.c
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H    -I/usr/include/mysql -DBIG_JOINS=1  -fno-strict-aliasing  -g -fPIC -fno-strict-aliasing -g -g -O2  -fPIC  -Wall -funroll-loops  -c mysql2_ext.c
./client.h:16:1: warning: ‘rb_thread_blocking_region’ defined but not used
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H    -I/usr/include/mysql -DBIG_JOINS=1  -fno-strict-aliasing  -g -fPIC -fno-strict-aliasing -g -g -O2  -fPIC  -Wall -funroll-loops  -c result.c
gcc -shared -o mysql2.so client.o mysql2_ext.o result.o -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/lib/x86_64-linux-gnu    -lruby1.8 -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl  -lpthread -lrt -ldl -lcrypt -lm   -lc
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1


Gem files will remain installed in /var/lib/gems/1.8/gems/mysql2-0.3.11 for inspection.
Results logged to /var/lib/gems/1.8/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

I've tried installing with mysql_config, I've installed the libmysqlclient-dev and libmysql-ruby libraries, I've tried uninstalling and reinstalling mysql. 我尝试使用mysql_config进行安装,已经安装了libmysqlclient-dev和libmysql-ruby库,还尝试了卸载并重新安装mysql。 None of it works. 没有一个有效。 I am able to successfully install mysql gem but not mysql2. 我能够成功安装mysql gem,但不能成功安装mysql2。

I'm running ruby1.8 and Rails 2.3.5. 我正在运行ruby1.8和Rails 2.3.5。 Can anyone help me out? 谁能帮我吗?

try this: 尝试这个:

sudo apt-get install libmysql-ruby 须藤apt-get install libmysql-ruby

sudo apt-get install libmysqlclient-dev sudo apt-get安装libmysqlclient-dev

sudo gem install mysql2 sudo gem安装mysql2

If you are running CentOS/Redhat, try install the following packages (using yum): 如果您正在运行CentOS / Redhat,请尝试安装以下软件包(使用yum):

MySQL-devel-5.5.22-1.el6.x86_64
MySQL-shared-5.5.22-1.el6.x86_64
MySQL-shared-compat-5.5.22-2.el6.x86_64

Look at this blog and others like it. 看这个博客和其他喜欢它的人。 But ultimately, I recommend upgrading from 11.04 to 11.10. 但最终,我建议从11.04升级到11.10。 I experienced many strange errors when running 11.04, since moving to 11.10 everything is much more stable. 在运行11.04时,我遇到了许多奇怪的错误,因为迁移到11.10后,一切都变得更加稳定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM