MySQL remote connection fails with “unknown authentication method”

前端 未结 7 1213
名媛妹妹
名媛妹妹 2020-11-28 15:22

I am trying to remotely connect to MySQL server online from my local machine, but I am getting the following error:

Warning: PDO::__construct(): The server r         


        
7条回答
  •  佛祖请我去吃肉
    2020-11-28 15:48

    I overcame the challenge. I found out that my remote MySQL database host still uses the old MySQL password hash which is 16-byte, while my localhost database server uses 41-byte password hash. I used the following query to find the password length:

    SELECT PASSWORD('mypass') 
    

    I changed my localhost database server password hash to 16-byte by running the following query

    SET GLOBAL old_passwords = 1;
    

    Then I edited my.ini file, and set the old_password=1 to ensure that when the server restarts, it won't revert to the new password system. But that didn't solve my problem.

    I figured out that it was PHP that handles the authentication, since I was using PHP's MySQL API, so I downgraded to PHP 5.2.8 and I was able to make the remote connection successfully.

    I hope this helps someone.

提交回复
热议问题