Friday, June 1, 2012

MySQL & PHP 5.4 incompatibility

I just upgraded from PHP 5.3 to 5.4 but now my scripts are showing this error

The server requested authentication method unknown to the client
So I run a search and found this

MySQL introduced longer password hashes in (i think) version 4.1, and your server probably still uses them (check for 16 byte password hashes in your mysql user table). Newer versions use longer password hashes. Your server supports both, but your client (php) seems to support only new ones in this version (and on).

The solution

First check if "old_passwords=1" is in your my.cnf. Remove that first then restart MySQL.

Then login to your MySQL server and run the command below.

SET PASSWORD FOR 'username'@'hostmask' = PASSWORD('thepassword')

No comments:

Post a Comment