Leaderboard (728 x 90)

Tuesday, July 24, 2012

PHP 4 can not connect to mysql server with error "Client does not support authentication protocol"


MySQL 4.1+ uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older (pre-4.1) clients. MySQL extension for PHP4 was compiled with old (pre-4.1) client library.

When you connect to server. It will shows error

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

To solve this problem, you should use one of the following approaches:
1. reset password to old style password

SET PASSWORD FOR 'some_user'@'some_host' = OLD_PASSWORD('newpwd');

For PHP mysql_connect command, you must specify parameters following

mysql_connect($server,$user,$pass,false,0);

2.Tell the server to use the older password hashing algorithm:
add this line to mysql configuration (my.ini/my.cnf)

[mysqld]
.
.
old-passwords = 1
.
.
[client]
.
.
old-passwords = 1
.
.

then restart service and reset password using command

SET PASSWORD FOR 'some_user'@'some_host' = PASSWORD('newpwd');

MySQL native driver for PHP can not connect to mysql. It shows error "mysqlnd cannot connect to MySQL 4.1+ using old authentication"

Symptom
MySQL native driver for PHP can not connect to mysql. It shows error "mysqlnd cannot connect to MySQL 4.1+ using old authentication"

Cause
New version of MySQL native driver for PHP uses an authentication protocol based on improved password hashing algorithm that is incompatible with an account that still has a pre-4.1-style password. 


Solution 
Reset the password to 4.1+ style for each user that needs to use the client program. 


SET SESSION OLD_PASSWORDS = FALSE; 
USE mysql;
UPDATE user SET password = PASSWORD('newpass') WHERE user='someuser'; 
FLUSH PRIVILEGES;