PHP 連線 mysql 出現 The server requested authentication method unknown to the client

旧的密码使用的长度是16位,新的密码长度是41位,所以连接不上

解法:

  1. 可以修改 mysql  配置
    登录
    #mysql -u root -p

    //生成新密码
    mysql > select password(‘密码’);

    //查询16位密码
    mysql > select old_password(‘密码);

    //使用新的41位密码更新旧的16位密码
    mysql > update  mysql.user set `Password` = ’41位密码’ where User = ‘用户名’  AND `Password` = ’16位密码’ ;

    //更新权限
    mysql > FLUSH PRIVILEGES;

  2. 另外还可以更新php版本到之前的5.2或5.3(未测试确认)

完成。