且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL远程连接失败,“身份验证方法未知"

更新时间:2023-12-04 23:21:22

我克服了挑战.我发现我的远程 MySQL 数据库主机仍然使用 16 字节的旧 MySQL 密码哈希,而我的 localhost 数据库服务器使用 41 字节的密码哈希.我使用以下查询来查找密码长度:

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') 

我通过运行以下查询将我的 localhost 数据库服务器密码哈希更改为 16 字节

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

SET GLOBAL old_passwords = 1;

然后我编辑了 my.ini 文件,并设置了 old_password=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.

我发现是 PHP 处理身份验证,因为我使用的是 PHPMySQL API,所以我降级为PHP 5.2.8 并且我能够成功建立远程连接.

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.