Click here to get back home

pure-perl access to mySQL

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
pure-perl access to mySQL klicker-mail 06-14-2005
Get Chitika Premium
Posted by Sherm Pendley on June 21, 2005, 7:45 am
Please log in for more thread options


klicker-mail@gmx.net writes:

> I'm still looking for a
> pure-perl solution like a simple module to communicate with mySQL.

Is there something wrong with the solutions easily found by searching CPAN
for "pure perl mysql"?

<http://search.cpan.org>

sherm--


Posted by klicker-mail on June 21, 2005, 9:19 am
Please log in for more thread options


> Is there something wrong with the solutions easily found by searching CPAN
> for "pure perl mysql"?

Yes!
Ok, what do we find?
-> Net::MySQL - as I said before, it is incompatible with mySQL4
-> DBD::mysql - together with DBI it uses C-libraries that have to be
compiled on every platform, so I cannot easily use it on Windows and
Unix, and that is what I want
-> DBD::mysqlPP - that is just the DBI-interface for Net::MySQL

And that's it. Believe me, I used CPAN, Google and others to look for a
platform-independent module, but I would not ask my question if I was
successful.

Any other ideas?

C u
Mario Fischer



Posted by Sherm Pendley on June 21, 2005, 12:20 pm
Please log in for more thread options


klicker-mail@gmx.net writes:

>> Is there something wrong with the solutions easily found by searching CPAN
>> for "pure perl mysql"?
>
> Yes!
> Ok, what do we find?
> -> Net::MySQL - as I said before, it is incompatible with mySQL4

You said that before? Oh, right - earlier in the thread. That's why it's
important to quote some context. People who view a message at a time, rather
than a whole thread at a time, can get confused if you don't. Thank you for
making that effort - it helps me help you.

At any rate, that's pretty odd. Nothing in the v4 release notes indicates
why that should be the case - in fact, it states that v3 clients should still
work.

So, I tested it - I installed Net::MySQL and ran a simple query against
a local installation of MySQL 4.1.11. It worked fine. One minor hiccup was
finding the unix socket - on my system it's /var/run/mysqld/mysqld.sock, not
/tmp/mysql.sock, which is what Net::MySQL wanted to connect to by default.
That was easily solved though, by providing that to the new() method:

my $mysql = Net::MySQL->new(
unixsocket => '/var/run/mysqld/mysqld.sock',
database => 'mysql',
user => 'root',
password => '*****'
);

> Any other ideas?

If nothing else works, you might try using DBD::Proxy. I've used that before,
to connect MacPerl scripts on classic MacOS - a platform where building a
"native" DBD::mysql was even more troublesome than on Windows.

sherm--


Posted by klicker-mail on June 22, 2005, 5:01 am
Please log in for more thread options


> So, I tested it - I installed Net::MySQL and ran a simple query against
> a local installation of MySQL 4.1.11. It worked fine. One minor hiccup was
> finding the unix socket - on my system it's /var/run/mysqld/mysqld.sock, not
> /tmp/mysql.sock, which is what Net::MySQL wanted to connect to by default.

Thanks for your effort. I also thought about the thing with the socket,
but it does not exist under Windows (as I said before, I want to be
platform-independent). With Net::MySQL you have the opporturnity to
provide a hostname, so the connection can be done by using IO::Socket.
Just try the following:

my $mysql = Net::MySQL->new(
hostname => 'localhost',
database => 'mysql',
user => 'root',
password => '*****'
);

...and look at the result - that is my problem (I do not want to force
the users of my scripts to use the older passwords just because of
compatibility).
The reason for the error-message is the new password-system that was
introduced by mySQL4 - it is incompatible with the one used by
mySQL3.x.
The new algorithm is nowhere really described and the source-code of
mySQL is no real 'revelation' ;-)

Btw: thanks for the hint with the quotes!

C u
Mario Fischer



Posted by Sherm Pendley on June 22, 2005, 3:39 pm
Please log in for more thread options


klicker-mail@gmx.net writes:

>> So, I tested it - I installed Net::MySQL and ran a simple query against
>> a local installation of MySQL 4.1.11. It worked fine.
>
> Just try the following:
>
> my $mysql = Net::MySQL->new(
> hostname => 'localhost',
....
>
> ..and look at the result

Works fine, connecting to a 4.1 server on localhost, and a 4.0 server on
another machine on my LAN. I expected it would; there's no reason to think
the encryption method used would be different for local vs. network clients.

> The reason for the error-message is the new password-system that was
> introduced by mySQL4 - it is incompatible with the one used by
> mySQL3.x.

Have a look here:

<http://dev.mysql.com/doc/mysql/en/old-client.html>

There are various methods you can use to enable old-style passwords, on a
global or per-user basis.

I took a closer look at my MySQL servers. According to the above page, the
new encryption was introduced in 4.1 - which is why I was able to connect to
the 4.0 server. The 4.1 server is the default Debian install, which enables
the old_passwords option in its config for compatibility.

sherm--


Similar ThreadsPosted
Perl under MS IIS with access to MySQL June 19, 2005, 11:24 pm
[RESOLVED] DBD::mysql unresolved symbol _intel_fast_memcpy & mysql-standard-5.0.22-linux-i686-icc-glibc23 August 29, 2006, 6:33 pm
MySQL 5.0 and Perl DBD-MySQL December 3, 2005, 1:10 am
Embedded mysql with DBD::mysql July 30, 2008, 10:15 am
DBD:mysql doesn't read mysql option file /etc/my.cnf file January 27, 2005, 11:19 pm
new module Logfile::Access October 23, 2004, 8:30 pm
Access a c++ module from Perl October 24, 2005, 6:21 pm
Microsoft Access & Win32::Ole October 28, 2005, 4:03 pm
Access DOM using JavaScript::SpiderMonkey January 16, 2006, 12:37 pm
compiling/add modules when no root access March 22, 2006, 4:21 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap