如何在 MySQL 5.7 中创建六个字符的密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34913266/
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
How to create a six character password in MySQL 5.7
提问by user3703723
I need to create a user with a six character password in new MySQL on my mac. I know that the lowest setting in 5.7 will allows only eight characters. Is there any way to go around that?
我需要在我的 mac 上的新 MySQL 中创建一个具有六个字符密码的用户。我知道 5.7 中的最低设置只允许八个字符。有什么办法可以解决这个问题吗?
I type in CREATE USER 'newsier'@'localhost' IDENTIFIED BY 'special'
我输入 CREATE USER 'newsier'@'localhost' IDENTIFIED BY 'special'
It outputs the error
它输出错误
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
采纳答案by miken32
You are using the password validation plugin. By default it only allows 8 characters and longer passwords. Because it can't check the value of a hash, @RiggsFolly is correct that pre-hashing the password will work.
您正在使用密码验证插件。默认情况下,它只允许 8 个字符和更长的密码。因为它无法检查散列的值,@RiggsFolly 是正确的,预散列密码将起作用。
However, if you want to change the options, you'll need to set the value of the validate_password_length
system variable. You can do this in the configuration file or:
但是,如果要更改 options,则需要设置validate_password_length
系统变量的值。您可以在配置文件中执行此操作或:
SET GLOBAL validate_password_length=6;
回答by Alexander Farber
First you login with mysql -u root -p
and check the current policy rules by:
首先,您登录mysql -u root -p
并通过以下方式检查当前策略规则:
# SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_dictionary_file | |
| validate_password_length | 5 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
Then you can change any of the above variables at your will:
然后您可以随意更改上述任何变量:
# SET GLOBAL validate_password_length = 5;
# SET GLOBAL validate_password_number_count = 0;
# SET GLOBAL validate_password_mixed_case_count = 0;
# SET GLOBAL validate_password_special_char_count = 0;
Finally you can create a database and a user accessing it with a simpler password:
最后,您可以创建一个数据库和一个使用更简单密码访问它的用户:
# CREATE DATABASE test1;
# GRANT ALL PRIVILEGES ON test1.* TO user1@localhost IDENTIFIED BY "pass1";
# FLUSH PRIVILEGES;
After that you can login with mysql -u user1 -p test1
using password pass1
之后,您可以mysql -u user1 -p test1
使用密码登录pass1
回答by Murtaza Kanchwala
MySQL 5.7+by default haves a Password validation system. In case if you don't want to go strictly with the policy and need to assign your own then just disable the password validation and restart mysqldprocess.
MySQL 5.7+默认有一个密码验证系统。如果您不想严格执行该策略并需要分配您自己的策略,则只需禁用密码验证并重新启动mysqld进程。
Edit my.cnffile :
编辑my.cnf文件:
vi /etc/my.cnf
in [mysqld]
在[mysqld]
validate-password=off
Save the file and then restartthe process
保存文件,然后重新启动该过程
sudo service mysqld restart
or
systemctl restart mysqld
and then change the Root Passwordusing the following and follow the steps it won't throw exception for the Root Password.
然后使用以下方法更改 Root 密码,并按照不会为 Root 密码引发异常的步骤进行操作。
mysql_secure_installation
or
/usr/bin/mysql_secure_installation
If you are doing installationfor the first timeand want to know the temporary passwordthen use the following to find the first time password:
如果你正在做安装的第一次,想知道的临时密码,然后使用以下方法来找到第一次密码:
grep 'temporary password' /var/log/mysqld.log
Let me know your comments on the same, in the below comment box.
在下面的评论框中让我知道您对此的评论。
回答by SeanDowney
It's possible to entirely disable the password "plugin" that seems overly strict by running the following:
uninstall plugin validate_password
通过运行以下命令,可以完全禁用看起来过于严格的密码“插件”:
uninstall plugin validate_password
Should you need it again you can turn it back on via:
INSTALL PLUGIN validate_password SONAME 'validate_password.so'
如果您再次需要它,您可以通过以下方式重新打开它:
INSTALL PLUGIN validate_password SONAME 'validate_password.so'
Optionally, you could disable it, set your password and re-enable it:
或者,您可以禁用它,设置密码并重新启用它:
uninstall plugin validate_password;
CREATE USER 'newsier'@'localhost' IDENTIFIED BY 'special';
INSTALL PLUGIN validate_password SONAME 'validate_password.so';
Further reading:
进一步阅读:
回答by Subarata Talukder
Check current password policy rules by
通过以下方式检查当前密码策略规则
SHOW VARIABLES LIKE 'validate_password%';
Now set new value of those variable:
现在设置这些变量的新值:
SET GLOBAL validate_password_length = 6 // that you like
SET GLOBAL validate_password_policy = 'LOW'
回答by RiggsFolly
I believe you can get round it by using a pre hashed password like this :-
我相信您可以通过使用这样的预散列密码来绕过它:-
CREATE USER 'newsier'@'localhost' IDENTIFIED WITH mysql_native_password
AS '*0D3CED9BEC10A777AEC23CCC353A8C08A633045E';
But that does mean you need to hash special
correctly before this will actually set a password that you can then use the plain text version of.
但这确实意味着您需要special
正确散列,然后才能实际设置密码,然后您可以使用纯文本版本。
回答by Naeem Sunesara
This might help:
这可能有帮助:
GRANT ALL ON wordpress.* TO 'user'@'localhost' IDENTIFIED WITH mysql_native_password AS'yourpassword';
GRANT ALL ON wordpress.* TO 'user'@'localhost' IDENTIFIED WITH mysql_native_password AS'yourpassword';