Mysql连接错误。 PDO抛出SQLSTATE [HY000] [2054]

I am trying to connect the mysql with PDO but having a problem.PDOException is throwing this problem :

PDO::__construct(): The server requested authentication method unknown to the client [mysql_old_password]

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

I have tried SET old_passwords = 0; But still not working.

You're close, but in the absence of any modifier, you were only setting a session variable.

To set a global variable, try this:

SET GLOBAL old_passwords=0

Or, better yet, edit your config file with old-passwords=0 and restart.

If you have old accounts with the old password format set, you'll need to upgrade them as well.