如何从 MySQL 旧密码升级到新密码系统

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8655997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 22:10:57  来源:igfitidea点击:

How to upgrade from MySQL old passwords to new Password system

mysqlpasswords

提问by Mahoor13

I have a lot of users (privilages) in mysql server 5.0 . I want to transfer all of them into new MySQL server 5.5 . But the passwords are in old format (in `mysql`.`user` table). So I want to convert all old passwords to new format.

我在 mysql server 5.0 中有很多用户(特权)。我想将它们全部转移到新的 MySQL 服务器 5.5 中。但是密码是旧格式(在`mysql`.`user`表中)。所以我想将所有旧密码转换为新格式。

Is there any way to transfer and upgrading the MySQL passwords without changing them?

有什么方法可以在不更改 MySQL 密码的情况下传输和升级它们?

回答by ClearCrescendo

Assuming you know the password you can

假设你知道密码,你可以

set password = password('samepasswordasbefore');

after old_passwords has been set to off for the server or the session.

在服务器或会话的 old_passwords 设置为关闭之后。

set old_passwords = 'OFF';

or

或者

set [session] old_passwords = 'OFF';

The server does not care/know that it is the same password as before.

服务器不关心/知道它与以前的密码相同。

As a result there is no risk to running software though from a security perspective you should change the passwords as the old one may have been compromised. Of course it would be even better to be forcing them to change periodically in which case you could just set old_passwords OFF and wait.

因此,运行软件没有风险,但从安全角度来看,您应该更改密码,因为旧密码可能已被盗用。当然,强制它们定期更改会更好,在这种情况下,您可以将 old_passwords 设置为 OFF 并等待。

Doing the set password in bulk isn't going to be so easy but if old_passwords has been OFF for some time there should only be a few accounts with old short hashes in user. You can at least identify those that have not been updated as those with a shorter hash in the user table.

批量设置密码不会那么容易,但是如果 old_passwords 已经关闭一段时间,那么用户中应该只有几个具有旧短哈希的帐户。您至少可以将那些尚未更新的内容标识为用户表中具有较短哈希值的内容。