MySQL under latest one-click installer

  • Thread starter R. Mark Volkmann
  • Start date
R

R. Mark Volkmann

Can it really be this hard to access MySQL from Ruby running under Windows?

Several people have emailed suggestions to me, but none are as simple as
1) download file x from site y
2) unzip file x
3) run this command to install it
4) use this API to access a MySQL database

Maybe the instructions people pointed me to work find under platforms other than
Windows or with other versions of Ruby than what is in the latest one-click
installer.

Accessing MySQL seems like a very basic requirement.
Surely someone working under Windows has needed to do this.
 
L

Lothar Scholz

Hello R.,

RMV> Maybe the instructions people pointed me to work find under platforms other than
RMV> Windows or with other versions of Ruby than what is in the latest one-click
RMV> installer.

RMV> Accessing MySQL seems like a very basic requirement.
RMV> Surely someone working under Windows has needed to do this.

You can use the pure ruby implementation of the mysql client. This one
works fine in a multithreaded application but is much slower. Its just
one file and a "require" statement.

I wish that the one click installer will include a lot more
binary modules in the future (as this is not well covered by
ruby-gems) and not 2 different Editors/Ide's.
 
J

James Britt

Lothar said:
I wish that the one click installer will include a lot more
binary modules in the future (as this is not well covered by
ruby-gems) and not 2 different Editors/Ide's.

Indeed. It is much easier to go get an editor or IDE than it is to get
binary modules.


James
 
R

R. Mark Volkmann

Quoting Lothar Scholz said:
Hello R.,

RMV> Maybe the instructions people pointed me to work find under platforms
other than
RMV> Windows or with other versions of Ruby than what is in the latest
one-click
RMV> installer.

RMV> Accessing MySQL seems like a very basic requirement.
RMV> Surely someone working under Windows has needed to do this.

You can use the pure ruby implementation of the mysql client. This one
works fine in a multithreaded application but is much slower. Its just
one file and a "require" statement.

I think that will be fine for my needs.

I downloaded ruby-mysql-0.2.6.tar.gz from
http://www.tmtm.org/en/ruby/mysql/README_en.html.

I unzipped it.

I ran "ruby setup.rb" and got
/setup.rb:8:in ``': No such file or directory - mysql_config --socket
(Errno::ENOENT) from ./setup.rb:8

Line 8 contains
sock = `mysql_config --socket`.chomp

I assume mysql_config is supposed to be an executable in the bin directory of
MySQL. It's not in mine. I have version 4.0.20a of MySQL.

Any ideas why the supplied install script doesn't work?
 
K

Kirk Haines

R. Mark Volkmann said:
Can it really be this hard to access MySQL from Ruby running under
Windows?

Several people have emailed suggestions to me, but none are as simple as
1) download file x from site y
2) unzip file x
3) run this command to install it
4) use this API to access a MySQL database

Yes, it is. I have MySQL running _right now_ on a WinXP box, accessed
through Ruby and DBI, and it was as simple as installing the one-click Ruby
installation. Installing ruby-mysql, and then installing dbi. Simple.


Kirk Haines
 
A

Adelle Hartley

Hi Mark,
Can it really be this hard to access MySQL from Ruby running
under Windows?

Several people have emailed suggestions to me, but none are
as simple as

I was previously able to connect to MySQL v 4.0.12 with the Ruby one-click
installer. I recently switched to MySQL v 4.1.9 and suddenly things got
difficult.

I found some instructions which said
1. install DBI
2. configure any databases that you want to access from Ruby, to use "old"
style password authentication (unencrypted).

Even following that advice, I have not been able to connect to MySQL 4.1.9
from Ruby unless the password is blank.

Adelle.
 
R

R. Mark Volkmann

Quoting (e-mail address removed):
Hi,

At Sat, 2 Apr 2005 13:56:22 +0900,
R. Mark Volkmann wrote in [ruby-talk:136452]:
I downloaded ruby-mysql-0.2.6.tar.gz from
http://www.tmtm.org/en/ruby/mysql/README_en.html.

| Setup
|
| % ruby ./setup.rb
|
| This command find MySQL's UNIX domain socket. This is not needed for system
that does not have UNIX
| domain socket such as Microsoft Windows.

Just to be clear, we're talking about using what is documented at
http://www.tmtm.org/en/ruby/mysql/README_en.html, not DBI.

So based on your advice I skipped "ruby setup.rb"
"ruby test.rb hostname user passwd" works!
"ruby install.rb" works!

When I run my code I get a dialog from ruby.exe titled "Unable To Locate
Component". It says "This application has failed to start because
mswin32-ruby16.dll was not found. Re-installing the application my fix this
problem."

Is that I file I should have gotten from the one-click installer?
Do I need it?
If so, where can I get it?
Where do I need to put it?
 
R

R. Mark Volkmann

Quoting Kirk Haines said:
Yes, it is. I have MySQL running _right now_ on a WinXP box, accessed
through Ruby and DBI, and it was as simple as installing the one-click Ruby
installation. Installing ruby-mysql, and then installing dbi. Simple.

If you go the RAA and search for MySQL, there are three different packages
called mysql-ruby. If I understand correctly, one is for Windows using DBI,
another is for everything else using DBI and the third is for every platform,
but not using DBI.

Can you tell me the URL of the mysql-ruby package that worked for you under
Windows? Do the installation instructions documented at the URL work for you
without modification?
 
R

R. Mark Volkmann

Quoting Adelle Hartley said:
Hi Mark,


I was previously able to connect to MySQL v 4.0.12 with the Ruby one-click
installer. I recently switched to MySQL v 4.1.9 and suddenly things got
difficult.

I found some instructions which said
1. install DBI
2. configure any databases that you want to access from Ruby, to use "old"
style password authentication (unencrypted).

Even following that advice, I have not been able to connect to MySQL 4.1.9
from Ruby unless the password is blank.

Ah ha! Someone else feels my pain. ;-)

Okay, has anyone successfully used MySQL 4.1 or higher under Windows with some
version of mysql-ruby? If so, what is the URL of the mysql-ruby package that
worked for you? Were you able to install it using the documented steps for
that package?
 
N

nobu.nokada

Hi,

At Sat, 2 Apr 2005 22:52:38 +0900,
R. Mark Volkmann wrote in [ruby-talk:136487]:
When I run my code I get a dialog from ruby.exe titled "Unable To Locate
Component". It says "This application has failed to start because
mswin32-ruby16.dll was not found. Re-installing the application my fix this
problem."

It is an old version DLL.
Is that I file I should have gotten from the one-click installer?
Do I need it?
If so, where can I get it?
Where do I need to put it?

You might execute wrong version ruby.exe.
a) check your PATH environment variable, and
b) check if old ruby.exe remain anywhere.
 
J

James Britt

R. Mark Volkmann said:
...
Ah ha! Someone else feels my pain. ;-)

Okay, has anyone successfully used MySQL 4.1 or higher under Windows with some
version of mysql-ruby? If so, what is the URL of the mysql-ruby package that
worked for you? Were you able to install it using the documented steps for
that package?


I've been using MySQL 4.1 on Windows with Ruby for about a month or so
now. The only issue I had was the change in the way MySQL does password
hashing (which can be corrected by telling MySQL to use the older
password hashing format).

I don't recall where I got my MySQL-Ruby libs; for some reason I had
thought they were included as part of the 1-Click installer, but I
gather that's not so.


Aside from various mysql libs included as part of other applications
(Og, Rails, etc.) I believe the only core lib I use is from TOMITA
Masahiro.

It's installed in c:\ruby\lib\1.8 and is a pure-Ruby lib.

I believe it came from http://www.tmtm.org/en/ruby/mysql/README_en.html

I'm guessing I followed the instructions on that page, though looking at
the content of the tarball there seems to be little for the installer to
do; it basically it just copies the file mysql.rb to the root of your
Ruby lib dir, something you could do by hand.



James

--

http://www.ruby-doc.org
http://www.rubyxml.com
http://catapult.rubyforge.com
http://orbjson.rubyforge.com
http://ooo4r.rubyforge.com
http://www.jamesbritt.com
 
R

R. Mark Volkmann

We have a winner! A big thanks goes out to James Britt!

Here are the steps I used to use MySQL with
the Ruby Windows one-click installer (version 1.8.2-14).

1) Download ruby-mysql-0.2.5.tar.gz
from http://www.tmtm.org/en/ruby/mysql/README_en.html.
2) Unzip this file.
3) Copy mysql.rb to $RUBY_HOME\lib\ruby\1.8.

Sample code:

require 'mysql'

host = 'localhost'
username = 'root'
password = ''
database = 'music'

begin
conn = Mysql.new(host, username, password, database)
rs = conn.query('select * from artists')
column_name = 'name'
rs.each_hash do |row|
puts "name = #{row[column_name]}"
end
rescue Mysql::Error => e
puts "Error! #{e.err}"
ensure
conn.close if conn
end

Maybe someday I'll figure out how to use the DBI API instead so my code won't be
tied to MySQL, but for now this will get me by.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top