PHP and MySQL 4.1: Connection problems
When setting up Drupal and phpBB with PHP 4.3.10, I upgraded to MySQL 4.1 and got this wonderful message:
Warning: mysql_connect(): Client does not support authentication protocol requested by server
Turns out that MySQL 4.1+ now uses longer and stronger SHA1 password hashes. This is a good thingTM because MD5 is not long-term secure as has been shown recently.1
For MySQL and PHP users, this change in password hashing complicates some setups. PHP 5+ programs won’t have problems if they use the mysqli function calls. PHP 4, however, has pre-MySQL 4.1 clients so they won’t be able to connect to new MySQL servers with the newer password hashes. The gory details can be seen here.
Enough with the techno-babble. You have two options:
- Run MySQL 4.1+ using the—old-passwords options.
- Explicitly issue MySQL commands to set the password to old password hashes. This can be done using the OLD_PASSWORD(’your_passwd’) as in the following:
[/textile]
SET PASSWORD FOR ‘user’@‘host’ = OLD_PASSWORD(‘user_password’);
[textile]
This SQL command replaces the user’s password with the older 14-byte MD5 password hash that older PHP-MySQL clients can deal with.