pure-perl access to mySQL

pure-perl access to mySQL

am 14.06.2005 16:38:47 von klicker-mail

Hi!

Since mySQL 3.2x there have been a lot of changes. But one was the most
significant to me: the new login process. This thing made Net::MySQL
unusable for mySQL 4.x.
Before I used Net::MySQL I tried DBI + DBD::mysql, but that was much
slower. So I appreciate the pure-perl-solution. I tried to adjust the
last version of Net::MySQL to work with the new login process, but the
new password algorithm is not documented anywhere and the source code
of mySQL does not push me further.

So, does anyone know another module for a pure-perl access to mySQL or
is there someone who already modified the old module?

Thanks for every hint!

C u
Mario Fischer

Re: pure-perl access to mySQL

am 15.06.2005 18:25:54 von Brian Jackson

klicker-mail@gmx.net wrote:

> Hi!
>
> Since mySQL 3.2x there have been a lot of changes. But one was the most
> significant to me: the new login process. This thing made Net::MySQL
> unusable for mySQL 4.x.
> Before I used Net::MySQL I tried DBI + DBD::mysql, but that was much
> slower. So I appreciate the pure-perl-solution. I tried to adjust the
> last version of Net::MySQL to work with the new login process, but the
> new password algorithm is not documented anywhere and the source code
> of mySQL does not push me further.
>
> So, does anyone know another module for a pure-perl access to mySQL or
> is there someone who already modified the old module?

Hi Mario-

While I don't have an answer to your direct question, you might be able to
'trick' the perl module to work with the new mysql version.

You can run the following from a mysql prompt to convert the passwds back to
the old style:

update user set password = old_password([put your passwd here]) where user
='[username]';

Give that a try and see if the perl mod works then.

good luck,
brian

Re: pure-perl access to mySQL

am 18.06.2005 17:34:05 von klicker-mail

Hi Brian,

I know, this 'trick' works. But my scripts + the module are often used
on shared servers, so the passwords cannot be changed.

Does no one know another solution?

C u
Mario

Re: pure-perl access to mySQL

am 18.06.2005 18:31:20 von Sherm Pendley

klicker-mail@gmx.net writes:

> I know, this 'trick' works. But my scripts + the module are often used
> on shared servers, so the passwords cannot be changed.
>
> Does no one know another solution?

What trick? What solution?

Please quote enough of the message you're replying to to provide some
context.

sherm--

Re: pure-perl access to mySQL

am 21.06.2005 12:45:52 von Sherm Pendley

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"?



sherm--

Re: pure-perl access to mySQL

am 21.06.2005 13:29:45 von klicker-mail

> [...] you might be able to
> 'trick' the perl module to work with the new mysql version.

> You can run the following from a mysql prompt to convert the passwds back to
> the old style:

> update user set password = old_password([put your passwd here]) where > user
> ='[username]';

This is the 'trick' I was talking about. And I'm still looking for a
pure-perl solution like a simple module to communicate with mySQL.

C u
Mario Fischer

Re: pure-perl access to mySQL

am 21.06.2005 17:19:00 von klicker-mail

> 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

Re: pure-perl access to mySQL

am 21.06.2005 17:20:23 von Sherm Pendley

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--

Re: pure-perl access to mySQL

am 22.06.2005 13:01:05 von klicker-mail

> 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

Re: pure-perl access to mySQL

am 22.06.2005 20:39:01 von Sherm Pendley

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:



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--