最大 MySQL 用户密码长度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7465204/
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 21:06:22  来源:igfitidea点击:

Maximum MySQL user password length

mysqlpasswords

提问by Chris

What is the maximum length for a MySQL user password?

MySQL 用户密码的最大长度是多少?

MySQL uses PASSWORD(str)to encrypt the cleartext password str. This hashed password string is stored in the mysql.usergrant table with a CHAR(41)datatype.

MySQL 用于PASSWORD(str)加密明文密码str。此散列密码字符串mysql.userCHAR(41)数据类型存储在授权表中。

However, I was not able to find what is the maximum length for the cleartext password str, if there is one. Can anyone help?

但是,我无法找到明文密码的最大长度str(如果有的话)。任何人都可以帮忙吗?

采纳答案by georgecj11

This is the reference pages I found when I googled : Link1and Link2

这是我在谷搜索时找到的参考页面: Link1Link2

If you are using MySQL Replication, be aware that, currently, a password used by a replication slave as part of a CHANGE MASTER TO statement is effectively limited to 32 characters in length; if the password is longer, any excess characters are truncated. This is not due to any limit imposed by the MySQL Server generally, but rather is an issue specific to MySQL Replication. (For more information, see Bug 43439.)

如果您使用 MySQL 复制,请注意,目前,复制从属服务器作为 CHANGE MASTER TO 语句的一部分使用的密码长度有效地限制为 32 个字符;如果密码更长,任何多余的字符都会被截断。这不是由于 MySQL 服务器通常施加的任何限制,而是特定于 MySQL 复制的问题。(有关更多信息,请参阅错误 43439。

Fix documented in the 5.7.5 changelog, as follows:

修复记录在5.7.5 变更日志中,如下:

The maximum length that can be used for the password in a CHANGE MASTER TO statement is 32 characters. Previously, when a longer password was employed, any excess length was silently truncated by the server. Now when the password's length exceeds 32 characters, CHANGE MASTER TO fails with an error.

CHANGE MASTER TO 语句中可用于密码的最大长度为 32 个字符。以前,当使用更长的密码时,任何多余的长度都会被服务器以静默方式截断。现在,当密码长度超过 32 个字符时,CHANGE MASTER TO 将失败并显示错误。

So I would safely assume my password should not be more than 32 characters.

所以我可以放心地假设我的密码不应超过 32 个字符。