2009-07-17 23 views
8

Khi tôi cố gắng kết nối với MySQL từ Sequel. Tôi gặp phải các lỗi này:Không thể kết nối mysql từ đá quý Sequel

require 'rubygems' 
     require 'sequel' 
     DB = Sequel.connect(:adapter => 'mysql', :user => 'root', :host => 'localhost', :database => 'scanty',:password=>'xx') 
     DB.tables 
    Sequel::DatabaseConnectionError: NameError uninitialized constant Mysql::CLIENT_MULTI_RESULTS 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:98:in `connect' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/database.rb:92:in `initialize' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:166:in `call' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:166:in `make_new' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:153:in `available' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:144:in `acquire' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:143:in `synchronize' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:143:in `acquire' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:105:in `hold' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/database.rb:471:in `synchronize' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:128:in `execute' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset.rb:314:in `execute' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:342:in `execute' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:298:in `fetch_rows' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset.rb:185:in `each' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset/convenience.rb:156:in `map' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset/convenience.rb:156:in `map' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/shared/mysql.rb:60:in `tables' 
     from (irb):6irb(main):007:0> Sequel::DatabaseConnectionError: NameErro 
+0

Dường như lỗi của bạn bị cắt bớt? Ngoài ra, máy chủ trong cuộc gọi hàm của bạn ở đâu? –

+0

Tôi đã thêm máy chủ nhưng vẫn có lỗi tương tự –

Trả lời

14

Bạn cần cài đặt trình điều khiển MySQL gốc, trình điều khiển thuần khiết không tương thích với Phần tiếp theo.

Tùy thuộc vào cài đặt Ruby của bạn, chỉ cần thực hiện gem install mysql có thể là đủ. Tuy nhiên, nếu tệp mysql.rb Ruby thuần túy đã có trong đường dẫn tải của Ruby, bạn cần xóa nó khỏi đường dẫn tải hoặc sử dụng gem('mysql') trước khi gọi Sequel.connect.

1

Bạn đang thiếu :host=>'localhost' hoặc bất kỳ máy chủ nào của bạn.

Ngoài ra, và điều này hoàn toàn chỉ vì lý do hiệu suất, bạn nên thử kích hoạt :compress. Nó có thể tiết kiệm một TON băng thông.

http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html

Sửa: OK, nếu nó không phải là chủ nhà, có lẽ đó là một cuộc xung đột? Xem http://groups.google.com/group/sequel-talk/browse_thread/thread/ee39640a92351f1?pli=1. Ngoài ra http://www.mail-archive.com/[email protected]/msg02275.html

+0

cảm ơn, Tôi có hai phiên bản của đá quý mysql được cài đặt trên máy. –

+0

Bạn có cố gắng khắc phục sự cố không? –

Các vấn đề liên quan