views:

690

answers:

2

I'm switching my app from using SQLite to MySQL. It works with SQLite and it's not working now that I've changed it to use MySQL. Here's the error message I'm getting:

Message: SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using old authentication

What does this mean?

Note: I'm running this locally running Snow Leopard, trying to access a remote database.

It's also dumping my username and password to the screen in plain text in the request parameters which is a little unsettling.

A: 

Andrew I think you have a problem with your MySQL client using old authentication.

You should make sure your PDO is using the last mysqlclient library.

you might want to test a PDO sample first to make sure everything is fine and after play with ZF.

 $db = new PDO("mysql:host=$host;dbname=$database", 
            $username, $password);

On your remark for Usernamer/Password , the Zend Framework documentation is stating that is the developer not to show those errors to user by setting different level of configuration in production and development. Zend_config is there for that, plus the error catching controller.

RageZ
this isn't running on a production server. Just on my computer and in development mode. So display_errors will be turned off in production mode.
Andrew
So is it that my MySQL server is old? Or is my PDO_MYSQL old? Is my PDO_MYSQL in Zend Framework, my local PHP installation, or my local MySQL installation?
Andrew
I tried out the app on my production server and I'm not getting the issue. What do I need to update on my end (locally) so this error doesn't reoccur
Andrew
I think you should check with wath libmysqlclient your PDO has been compiled against
RageZ
+2  A: 

Are you running PHP 5.3? mysqlnd is the new native MySQL driver for PHP (ext/mysql, ext/mysqli and PDO make use of it, so it is not a new API but a new way how the three different APIs communicate with the MySQL server) - here is a nice article about mysqlnd.

The problem now is that your MySQL server uses an old authentication mechanism which mysqlnd is not able to comply with. mysqlnd needs the new 41 bytes password that was introduced with MySQL 4.1 (so you cannot connect to MySQL servers < 4.1). To update your user table to use the new password scheme you have to use the SET PASSWORD command on your MySQL server, e.g.:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypassword');

This changes the password scheme and will allow you to connect with mysqlnd. Here Thomas Rabaix describes exactly the same problem - just for reference.

Stefan Gehrig