2012-04-11 81 views
6

Tôi đang cố gắng cài đặt mysql2 trên máy chủ. nên đường mòn không may mắn đầu tiên của tôi là như sauLỗi khi cài đặt mysql2

gem install mysql2 

đầu ra

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_query() in -lmysqlclient... no 
checking for main() in -lm... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lz... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lsocket... no 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lnsl... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lmygcc... no 
checking for mysql_query() in -lmysqlclient... no 
*** 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/bin/ruby1.8 
    --with-mysql-config 
    --without-mysql-config 
    --with-mysql-dir 
    --without-mysql-dir 
    --with-mysql-include 
    --without-mysql-include=${mysql-dir}/include 
    --with-mysql-lib 
    --without-mysql-lib=${mysql-dir}/lib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-mlib 
    --without-mlib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-zlib 
    --without-zlib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-socketlib 
    --without-socketlib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-nsllib 
    --without-nsllib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-mygcclib 
    --without-mygcclib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 


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

đây không phải là kết thúc của câu chuyện

sau khi chạy

[ps89405]$ mysql --help | grep Default -A 1 
Default options are read from the following files in the given order: 
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf 

tôi đã cố gắng

gem install mysql2 -- --with-mysql-config=~/.my.cnf --ruby=/usr/bin/ruby1.8 

gem install mysql2 -- --with-mysql-config=/usr/etc/my.cnf --ruby=/usr/bin/ruby1.8 

gem install mysql2 -- --with-mysql-config=/etc/my.cnf --ruby=/usr/bin/ruby1.8 

không có may mắn cùng một lỗi.

Tôi không chạy RVM

và env đá quý của tôi là

RubyGems Environment: 
    - RUBYGEMS VERSION: 1.3.7 
    - RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux] 
    - INSTALLATION DIRECTORY: /home/aaalsubaie/.gems/ 
    - RUBY EXECUTABLE: /usr/bin/ruby1.8 
    - EXECUTABLE DIRECTORY: /home/aaalsubaie/.gems/bin 
    - RUBYGEMS PLATFORMS: 
    - ruby 
    - x86_64-linux 
    - GEM PATHS: 
    - /home/aaalsubaie/.gems/ 
    - /usr/lib/ruby/gems/1.8 
    - GEM CONFIGURATION: 
    - :update_sources => true 
    - :verbose => true 
    - :benchmark => false 
    - :backtrace => false 
    - :bulk_threshold => 1000 
    - REMOTE SOURCES: 
    - http://rubygems.org/ 

này là ngày thứ hai của tôi trên hàng cố gắng để triển khai ứng dụng đường ray đầu tiên của tôi không có may mắn tôi mặc dù nó sẽ được dễ dàng hơn nhiều.

update:

nay là lệnh đang làm việc và cài đặt mysql2 đá quý nhờ Yanhao

gem install mysql2 -- --with-mysql-config=/usr/bin/mysql_config 

Tôi có vấn đề mới bây giờ với mysql2 đá quý khi tôi chạy

bundle exec rails console 

tôi

/home/aaalsubaie/ajhezaty.com/releases/20120411095320/vendor/bundle/ruby/1.8/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require': no such file to load -- mysql2/mysql2 (LoadError) 
from /home/aaalsubaie/ajhezaty.com/releases/20120411095320/vendor/bundle/ruby/1.8/gems/mysql2-0.3.11/lib/mysql2.rb:9 
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require' 
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require' 
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in `each' 
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in `require' 
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in `each' 
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in `require' 
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler.rb:112:in `require' 
from /home/aaalsubaie/ajhezaty.com/releases/20120411095320/config/application.rb:7 
from /home/aaalsubaie/ajhezaty.com/releases/20120411095320/vendor/bundle/ruby/1.8/gems/railties-3.2.1/lib/rails/commands.rb:39:in `require' 
from /home/aaalsubaie/ajhezaty.com/releases/20120411095320/vendor/bundle/ruby/1.8/gems/railties-3.2.1/lib/rails/commands.rb:39 
from script/rails:6:in `require' 
from script/rails:6 

Trả lời

3

Lệnh nên như thế này:

gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config 

Option "với-mysql-config" đề cập đến công cụ "mysql_config", thay vì các tập tin cấu hình.

Và bạn nên làm tốt hơn tệp mkmf.log.

+1

/usr/local/mysql/bin/không tồn tại trong máy chủ của tôi! Tôi cũng không hiểu dòng cuối cùng của bạn. – aaalsubaie

+0

cảm ơn nó hoạt động sau khi cài đặt thư viện dev. Tôi có vấn đề mới bây giờ bạn có thể đọc bản cập nhật của tôi về câu hỏi trên. – aaalsubaie

+0

Còn một gói 'cài đặt khác'? – Reactormonk

14

này có thể không có liên quan trực tiếp đến bạn, nhưng tôi phải đối mặt với vấn đề chính xác cùng, và tôi nghĩ rằng câu trả lời của tôi có thể giúp đỡ người khác với vấn đề này:

sudo apt-get install libmysql-ruby 
sudo apt-get install libmysqlclient-dev 
sudo gem install mysql2 

Đó làm việc cho tôi.

+0

cảm ơn, thời gian đã lưu) – ajahongir

+0

cảm ơn bạn đã tiết kiệm thời gian của tôi :) –

+0

+1. Cảm ơn điều này đã giúp ... –

4

Nếu bạn đang sử dụng máy Mac, hãy cài đặt MySQL với Homebrew brew install mysql và điều đó sẽ cho phép bạn cài đặt đá quý sau đó.

0

Trước tiên, bạn phải chạy lệnh này:

sudo apt-get install libmysqlclient-dev 

và sau đó bạn có thể chạy này:

gem install mysql2 

nó phải làm việc ..

0

sudo apt-get cài đặt libmysqlclient-dev hệ thống sẽ cài đặt hai thư viện lib khác: mysql-common libmysqlclient16

0

"Bảng điều khiển đường ray gói exec" chạy với Gemfile của trình bundler, nhưng bạn đã cài đặt mysql2 bằng rubygems. Bạn sẽ cần phải chạy:

gem uninstall mysql2    # uninstall mysql2 from system 
bundle exec gem uninstall mysql2 # uninstall mysql2 from bundler 
bundle config build.mysql2 --with-mysql-config=/usr/bin/mysql_config # set build option for mysql2 gem 
bundle install     # reinstall mysql2 
bundle exec rails console   # start rails console using the rails exec installed via bundler 

Lưu ý bổ sung: Nếu bạn đang sử dụng chở khách và bạn chỉ cần cập nhật phiên bản Ruby của bạn, hãy chắc chắn để cài đặt lại hành khách và cập nhật httpd.conf của bạn để bắt đầu máy chủ thành công.