1

Using ruby gem 'sequel', when I attempt Sequel.connect("mysql://localhost"), I get the following error:

Sequel::AdapterNotFound: LoadError: require 'mysql' did not define Mysql::CLIENT_MULTI_RESULTS!
  You are probably using the pure ruby mysql.rb driver,
  which Sequel does not support. You need to install
  the C based adapter, and make sure that the mysql.so
  file is loaded instead of the mysql.rb file.

How can I get this gem to connect to a MySQL server?

Sys: Win XP, Ruby 1.8.7, Mysql 5.1.51

JellicleCat
  • 28,480
  • 24
  • 109
  • 162
  • I have found the recommendation to run something along the following lines in multiple places: `sudo env ARCHFLAGS="-arch x86_64" gem install ruby-mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config` However, I'm running Windows, so I tried `gem install ruby-mysql -- --with-mysql-config="C:\Program Files\...\my.ini"` (I don't know that my.ini is my config file.) – JellicleCat Aug 08 '11 at 18:19

2 Answers2

2

Found the solution on this thread: Unable to connect mysql from Sequel gem

Call gem('mysql') to specify use of the native sql driver before Sequel.connect().

(Upvotes for Jeremy Evans)

Community
  • 1
  • 1
JellicleCat
  • 28,480
  • 24
  • 109
  • 162
1

Sequel is an ORM on top of existing Database adapters.

The error you're receiving is because mysql gem has not been installed.

You should be able to solve this problem doing gem install mysql

Since MySQL gem on Windows is provided as binaries, it is very sensible in relation to the dependency of libmysql.dll available in your system.

I recommend you the following tutorial I put together to cover the proper installation of the gem against modern versions of MySQL:

http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

Hope this helps.

Luis Lavena
  • 10,348
  • 1
  • 37
  • 39
  • So now I've carried out the instructions you provided, but when I try to use Sequel, I get the same error I listed up top. – JellicleCat Aug 09 '11 at 18:14
  • So did you install the mysql gem? does it work from IRB like the article I linked? What does `puts Mysql::CLIENT_MULTI_RESULTS` output in the IRB console? – Luis Lavena Aug 09 '11 at 19:44
  • I did install the mysql gem, and I did succeed in using to connect to my local server. ... The command in your last comment returns `NameError: uninitialized constant Mysql::CLIENT_MULTI_RESULTS`. ... I have not been able to use the mysql gem to connect to the remote server at work because of the following error: `Mysql::Error: Client does not support authentication protocol requested by server; consider upgrading MySQL client`, which is why I'm trying to get the sequel gem to work for a mysql connection. – JellicleCat Aug 09 '11 at 20:50