fruitbeeriswrong has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I wonder if anyone can help me?. I've got a problem getting connections to a MySQL database. Basically I developed the code on my machine at home before uploading it to the web hosting company. Everything worked fine at home but at the host company my connections to MySQL stopped working with the

Client does not support authentication protocol requested by server; consider upgrading MySQL client

error. A quick search of the internet later and everyone said it was problem to do with MySQL hashing algorithm changing (http://dev.mysql.com/doc/refman/4.1/en/old-client.html). The main suggestion (other than upgrading the client) is to use the old_password function. My ISP does not give me permission to run this so I can't use this work around. Before I pinged an email to the ISP I thought I'd just check the DBI and DBD versions on both sides. Bizarrely the ones at the ISP were more up-to-date than mine?
To recap,

This works..
DBI Version 1.38
DBD Version 2.9007

This doesn't ..
DBI Version 1.50
DBD Version 3.0002


I'm connecting my home code directly to the MySQL database at the ISP so all tests are running against the same MySQL database (Version 4.1.14). Example code..
#!/usr/bin/perl use DBI; use DBD::mysql; print q(Content-Type: text/html; charset=ISO-8859-1 ); print "DBI Version=" . $DBI::VERSION; print "<BR>DBD Version=" . $DBD::mysql::VERSION; $dbh = DBI->connect("DBI:mysql:<DATABASE NAME>:localhost","<USERNAME>" +,"<PASSWORD>") or print "<BR>Couldn't connect to database: " . DBI->errstr; $query=q{select user()}; $sth = $dbh->prepare($query); $sth->execute(); my $user_info; $sth->bind_columns(\$user_info); $sth->fetch(); print "<BR> User connected to MySql: $user_info";
Does anyone have any ideas?

Replies are listed 'Best First'.
Re: MySQL DBI Woe
by monarch (Priest) on Jan 24, 2006 at 04:45 UTC
    This problem drove me up the wall and back, why MySQL made their client library of version 3 incompatible with the server of version 4 I don't know!

    If you're using DBD on the ISP and the database on the ISP, then it is up to them to make sure they are using compatible client and server libraries.

    If you're using DBD at home, and connecting to the database on the ISP, then you'll have to ensure you're using the same client library version as the server version used in the states.

    This isn't going to be solved any other way than ensuring client/server major version numbers are the same..

      Thanks for this. It sounds like I'm not going mad after all :) I've contacted my ISP and asked them to look at upgrading (or even downgrading would help!!) the version of DBD. Cheers Liam
Re: MySQL DBI Woe
by badaiaqrandista (Pilgrim) on Jan 24, 2006 at 04:21 UTC
    Probably the DBD was compiled against an old mysql library? I don't know much about mysql DBD, but I guess it is in XS so it connects to the server through the mysql C library. Probably asking in dbi-users mailing list would help you better.
    --------------
    badaiaqrandista
Re: MySQL DBI Woe
by jZed (Prior) on Jan 23, 2006 at 19:21 UTC
    If you google for the text of your error message (a good thing to try in all cases) you'll find the first hit on "mysql authentication protocol" is a reference to the MySQL site and probably solves your problem. On more careful re-reading of your post, I see you already found this, sorry.