2011-06-21 49 views
0

我有點困惑與MySQL的寶石安裝錯誤。由於MySQL從5.0.xx更新到5.1.39,我卸載了mysql gem,現在我無法正確安裝它。MySQL的寶石安裝問題

我已將mysql-2.8.1.gem下載到服務器,因爲它位於代理之後。我有很多教程,其中告訴我必須包含mysql_config來擺脫此錯誤,但沒有幫助。

操作系統是紅帽企業Linux服務器版本5.3(Tikanga)。

[[email protected] ~]$ 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 

有什麼建議嗎?

+0

我遇到了和你一樣的錯誤信息。只是不明白髮生了什麼。 – Pok

回答

0

從錯誤,它看起來好像你的MySQL版本是不是與您正在使用的寶石版本兼容。

/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的版本。

0

我建議你使用mysql2 gem。如果你使用ruby 1.8系列,你應該使用寶石版本0.2.11或0.2.13或者如果你使用ruby 1.9系列,我會推薦寶石版本0.3.7。 0.3.X由於某種原因在Ruby 1.8上不起作用。

它應該像一個魅力。 :)