0

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.

2
  • DB usernames and passwords are one reason why errors should never be displayed on a production server. Commented Nov 13, 2009 at 4:50
  • not the database username/password, my user login credentials for my app. Also, this isn't running on a production server. Just on my computer and in development mode. Errors are turned off on production mode. Commented Nov 13, 2009 at 5:09

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

4 Comments

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.
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?
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
I think you should check with wath libmysqlclient your PDO has been compiled against
0

Use this to solve your problem :)

SET SESSION old_passwords = 0;
SELECT @@global.old_passwords, @@session.old_passwords, Length(PASSWORD('abc'));
SET PASSWORD = PASSWORD('abc')

Good Luck

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.