2012-06-20 59 views
2

我使用的是Centos 5.8,mysql5.5,ruby 1.9.1,rails 3.0.9和mysql2 -v 0.2.7 gem。獲取錯誤'mysql.h is missing'捆綁安裝ROR

雖然做 '包安裝',我得到這個錯誤:

Installing mysql2 (0.2.7) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

/usr/local/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes 
checking for mysql.h... no 
checking for mysql/mysql.h... no 
----- 
mysql.h is missing. please check your installation of mysql and try again. 
----- 
*** extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of 
necessary libraries and/or headers. Check the mkmf.log file for more 
details. You may need configuration options. 

Provided configuration options: 
    --with-opt-dir 
    --without-opt-dir 
    --with-opt-include 
    --without-opt-include=${opt-dir}/include 
    --with-opt-lib 
    --without-opt-lib=${opt-dir}/lib 
    --with-make-prog 
    --without-make-prog 
    --srcdir=. 
    --curdir 
    --ruby=/usr/local/bin/ruby 
    --with-mysql-config 
    --without-mysql-config 


Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.2.7 for inspection. 
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.2.7/ext/mysql2/gem_make.out 
An error occured while installing mysql2 (0.2.7), and Bundler cannot continue. 
Make sure that `gem install mysql2 -v '0.2.7'` succeeds before bundling. 

我探索各種solutions.eg。我嘗試這樣做:

sudo yum install mysql-devel 

,並得到這個錯誤:

Loaded plugins: dellsysid, fastestmirror 
Loading mirror speeds from cached hostfile 
* base: mirror.hmc.edu 
* epel: linux.mirrors.es.net 
* extras: centos.mirrors.hoobly.com 
* updates: centos.sonn.com 
Setting up Install Process 
Resolving Dependencies 
--> Running transaction check 
---> Package mysql-devel.i386 0:5.0.95-1.el5_7.1 set to be updated 
---> Package mysql-devel.x86_64 0:5.0.95-1.el5_7.1 set to be updated 
--> Processing Dependency: libmysqlclient_r.so.15()(64bit) for package: mysql-devel 
--> Processing Dependency: libmysqlclient.so.15()(64bit) for package: mysql-devel 
--> Finished Dependency Resolution 
mysql-devel-5.0.95-1.el5_7.1.x86_64 from updates has depsolving problems 
    --> Missing Dependency: libmysqlclient.so.15()(64bit) is needed by package mysql-devel-5.0.95-1.el5_7.1.x86_64 (updates) 
mysql-devel-5.0.95-1.el5_7.1.x86_64 from updates has depsolving problems 
    --> Missing Dependency: libmysqlclient_r.so.15()(64bit) is needed by package mysql-devel-5.0.95-1.el5_7.1.x86_64 (updates) 
Error: Missing Dependency: libmysqlclient.so.15()(64bit) is needed by package mysql-devel-5.0.95-1.el5_7.1.x86_64 (updates) 
Error: Missing Dependency: libmysqlclient_r.so.15()(64bit) is needed by package mysql-devel-5.0.95-1.el5_7.1.x86_64 (updates) 

安裝的libmysqlclient-dev的libmysqlclient16也未在CentOS工作作爲沒有這樣的包

請提出解決方案。

謝謝。

+0

mysql.h實際上是否安裝在任何地方? – thisfeller

+0

在StackOverflow上重複上千次,例如[通過Bundler安裝mysql2 gem的錯誤](http://stackoverflow.com/questions/3754662/errors-installing-mysql2-gem-via-the-bundler) –

回答

2

這個問題通過安裝mysql-devel 5.5得到解決。早些時候爲mysql5.5安裝了mysql-devel 5.0。

-1

首先爲你的mysql數據庫下載服務器。 並複製文件「libmysql.dll」,這是在MySQL中// bin,並將其粘貼到「Ruby \ bin」 並重新啓動服務器。