MySql 密码中的特殊字符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21266059/
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
Special characters in MySql Password
提问by csi
Our app continues to have problem with MySql passwords. We would like to create a function to test for password validity before it is presented to the database.
我们的应用程序仍然存在 MySql 密码问题。我们想创建一个函数来在密码提交给数据库之前测试密码的有效性。
Can anyone direct me to guidelines for MySql passwords involving these 2 topics:
任何人都可以指导我了解涉及这两个主题的 MySql 密码指南:
- password max length (hash is stored as 16 bit varchar which does not mean 16 is max length)
- which punctuation / special characters can be used in a MySql password?
- 密码最大长度(哈希存储为 16 位 varchar,这并不意味着 16 是最大长度)
- MySql 密码中可以使用哪些标点符号/特殊字符?
采纳答案by Bill Karwin
MySQL 5.6.6 is the first release that has any password strength guidelines or enforcement.
MySQL 5.6.6 是第一个具有任何密码强度指南或强制执行的版本。
See https://dev.mysql.com/doc/refman/5.6/en/validate-password.html
见https://dev.mysql.com/doc/refman/5.6/en/validate-password.html
But for what it's worth, there have never been any restrictions on the length of a password or characters supported. MySQL stores a hash of the password string, not the string itself, and hashes are always stored as a fixed length string of hexadecimal digits, not the plaintext password.
但就其价值而言,对密码长度或支持的字符从来没有任何限制。MySQL 存储密码字符串的哈希值,而不是字符串本身,并且哈希值始终存储为固定长度的十六进制数字字符串,而不是明文密码。
You aren't specific about what problems your app is having with MySQL passwords. Perhaps if you edit your question to describe these problems in more detail, you can get a more specific answer.
您没有具体说明您的应用程序在使用 MySQL 密码时遇到了什么问题。也许如果您编辑您的问题以更详细地描述这些问题,您可以获得更具体的答案。
回答by EricH
I'm using MariaDB 10.0.13 - the '\' character is a bit special. If defining a password using PASSWORD('text'), make sure to escape use of '\'.
我使用的是 MariaDB 10.0.13 - '\' 字符有点特殊。如果使用 PASSWORD('text') 定义密码,请确保避免使用 '\'。
Example: set password for user@localhost = PASSWORD('\\');
示例:为 user@localhost = PASSWORD('\\') 设置密码;
You can then use a single '\' for the password with mysql: mysql -u user --password='\'
然后,您可以使用单个 '\' 作为 mysql 的密码: mysql -u user --password='\'
回答by Sujit Rai
As per this mail list, by default password length is 16 characters but you can change it by alter table command.
根据此邮件列表,默认密码长度为 16 个字符,但您可以通过 alter table 命令更改它。
For special characters there is no specific documentation about allowed password characters. but on this link it is written that all of the ASCII characters are allowed for password. http://dev.mysql.com/doc/refman/5.6/en/user-names.html
对于特殊字符,没有关于允许的密码字符的特定文档。但在此链接上写到所有 ASCII 字符都允许用于密码。http://dev.mysql.com/doc/refman/5.6/en/user-names.html