MySQL 如何关闭mysql密码验证?

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

How do I turn off the mysql password validation?

mysql

提问by Alex Ryan

It seems that I may have inadvertently loaded the password validation plugin in MySQL 5.7. This plugin seems to force all passwords to comply to certain rules.

看来我可能不小心在 MySQL 5.7 中加载了密码验证插件。这个插件似乎强制所有密码遵守某些规则。

I would like to turn this off.

我想关闭它。

I've tried changing the validate_password_length variable as suggested hereto no avail.

我尝试按照此处的建议更改 validate_password_length 变量,但无济于事。

mysql> SET GLOBAL validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)

mysql> SET PASSWORD FOR 'app' = PASSWORD('abcd');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

I would like to either unload the plugin or neuter it somehow.

我想卸载插件或以某种方式中性它。

回答by Ray Hunter

Here is what I do to remove the validate password plugin:

这是我删除验证密码插件的操作:

  1. Login to the mysql server as root mysql -h localhost -u root -p
  2. Run the following sql command: uninstall plugin validate_password;
  3. If last line doesn't work (new mysql release), you should execute UNINSTALL COMPONENT 'file://component_validate_password';
  1. 以root身份登录mysql服务器 mysql -h localhost -u root -p
  2. 运行以下sql命令: uninstall plugin validate_password;
  3. 如果最后一行不起作用(新的 mysql 版本),您应该执行 UNINSTALL COMPONENT 'file://component_validate_password';

I would not recommend this solution for a production system. I used this solution on a local mysql instance for development purposes only.

我不会为生产系统推荐这个解决方案。我在本地 mysql 实例上使用此解决方案仅用于开发目的。

回答by Akshay Gaur

I am using MySQL v 8.0.12 and the command to disablepassword validation component is:

我使用的是 MySQL v 8.0.12,禁用密码验证组件的命令是:

UNINSTALL COMPONENT 'file://component_validate_password';

To install it back again, the command is:

要重新安装它,命令是:

INSTALL COMPONENT 'file://component_validate_password';

If you just want to changethe policy of password validation plugin:

如果您只想更改密码验证插件的策略:

SET GLOBAL validate_password.policy = 0;   // For LOW
SET GLOBAL validate_password.policy = 1;   // For MEDIUM
SET GLOBAL validate_password.policy = 2;   // For HIGH

回答by ktbos

Building on the answer from Sharfi, edit the /etc/my.cnf file and add just this one line:

基于 Sharfi 的答案,编辑 /etc/my.cnf 文件并仅添加这一行:

validate_password_policy=LOW

That should sufficiently neuter the validation as requested by the OP. You will probably want to restart mysqld after this change. Depending on your OS, it would look something like:

这应该足以使 OP 要求的验证无效。您可能希望在此更改后重新启动 mysqld。根据您的操作系统,它看起来像:

sudo service mysqld restart

validate_password_policy takes either values 0, 1, or 2 or words LOW, MEDIUM, and STRONG which correspond to those numbers. The default is MEDIUM (1) which requires passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters. Changing to LOW as I suggest here then only will check for length, which if it hasn't been changed through other parameters will check for a length of 8. If you wanted to shorten that length limit too, you could also add validate_password_length in to the my.cnf file.

validate_password_policy 采用值 0、1 或 2 或与这些数字对应的单词 LOW、MEDIUM 和 STRONG。默认为 MEDIUM (1) 要求密码至少包含 1 个大写字母、1 个小写字母、1 位数字和 1 个特殊字符,并且密码总长度至少为 8 个字符。更改为 LOW 就像我在这里建议的那样只会检查长度,如果它没有通过其他参数更改,则会检查长度为 8。如果您也想缩短该长度限制,您还可以将 validate_password_length 添加到my.cnf 文件。

For more info about the levels and details, see the mysql doc.

有关级别和详细信息的更多信息,请参阅mysql 文档



For MySQL 8, the property has changed from "validate_password_policy" to "validate_password.policy". See the updated mysql docfor the latest info.

对于 MySQL 8,该属性已从“validate_password_policy”更改为“validate_password.policy”。有关最新信息,请参阅更新的mysql 文档

回答by lav

To disable password checks in mariadb-10.1.24 (Fedora 24) I had to comment out a line in /etc/my.cnf.d/cracklib_password_check.cnffile:

要在 mariadb-10.1.24 (Fedora 24) 中禁用密码检查,我必须在/etc/my.cnf.d/cracklib_password_check.cnf文件中注释掉一行:

;plugin-load-add=cracklib_password_check.so

then restart mariadb service:

然后重启 mariadb 服务:

systemctl restart mariadb.service

回答by Sharfi

You can configure this in mysql configuration file open /etc/my.cnffile In this file all the lines which is configuring the password policy make those commented like

你可以在 mysql 配置文件中配置这个 open /etc/my.cnffile 在这个文件中,所有配置密码策略的行都被注释为

#validate-password=FORCE_PLUS_PERMANENT
#validate_password_length=10
#validate_password_mixed_case_count=1
#validate_password_number_count=1
#validate_password_policy=MEDIUM

Uncomment and change the value of the properties you want to change.

取消注释并更改要更改的属性的值。

回答by SeanDowney

If you want to make exceptions, you can apply the following "hack". It requires a user with DELETEand INSERTprivilege for mysql.pluginsystem table.

如果你想例外,你可以应用下面的“hack”。它需要具有系统表DELETEINSERT特权的用户mysql.plugin

uninstall plugin validate_password;
SET PASSWORD FOR 'app' = PASSWORD('abcd');
INSTALL PLUGIN validate_password SONAME 'validate_password.so';

Bland security disclaimer: Consider, why you are making your password shorter or easier and perhaps consider replacing it with one that is more complex. However, I understand the "it's 3AM and just needs to work" moments, just make sure you don't build a system of hacks, lest you yourself be hacked

平淡的安全免责声明:考虑一下,为什么要让密码更短或更容易,也许可以考虑用更复杂的密码替换它。然而,我理解“现在是凌晨 3 点,只需要工作”的时刻,只要确保你没有建立一个黑客系统,以免你自己被黑客入侵

回答by Paul Pritchard

Further to the answer from ktbos:

进一步来自 ktbos 的回答:

I modified the mysqld.cnf file and mysql failed to start. It turned out that I was modifying the wrong file!

我修改了mysqld.cnf文件,mysql启动失败。原来是我修改了错误的文件!

So be sure the file you modify contains segment tags like [mysqld_safe] and [mysqld]. Under the latter I did as suggested and added the line:

因此,请确保您修改的文件包含 [mysqld_safe] 和 [mysqld] 等段标记。在后者下,我按照建议做了并添加了以下行:

validate_password_policy=LOW

This worked perfectly to resolve my issue of not requiring special characters within the password.

这完美地解决了我在密码中不需要特殊字符的问题。

回答by Antonio Bardazzi

Uninstall:

卸载:

mysql> uninstall plugin validate_password;

An uninstalled plugin is not displayed by show plugins;

卸载的插件不显示 show plugins;

Install:

安装:

mysql> install plugin validate_password SONAME 'validate_password.so';

Disabled by configuration:

通过配置禁用:

[mysqld]
validate_password = OFF

A plugin can be disabled by configuration only if installed.

只有安装了插件才能通过配置禁用插件。

回答by Otheus

On some installations, you cannot execute this command until you have reset the root password. You cannot reset the root password, until you execute this command. Classic Catch-22.

在某些安装中,您必须重置 root 密码才能执行此命令。在执行此命令之前,您无法重置 root 密码。经典第 22 条军规。

One solution not mention by other responders is to temporarily disable the plugin via mysql configuration. In any my.cnf, in the [mysqld]section, add:

其他响应者未提及的一种解决方案是通过 mysql 配置暂时禁用插件。在任my.cnf,在[mysqld]一节增加:

skip-validate_password=1

and restart the server. Change the password, and set the value back to 0, and restart again.

并重新启动服务器。更改密码,并将值重新设置为 0,然后重新启动。

回答by gabrielstuff

For references and the future, one should read the doc here https://dev.mysql.com/doc/mysql-secure-deployment-guide/5.7/en/secure-deployment-password-validation.html

对于参考和未来,人们应该在这里阅读文档https://dev.mysql.com/doc/mysql-secure-deployment-guide/5.7/en/secure-deployment-password-validation.html

Then you should edit your mysqld.cnffile, for instance :

然后你应该编辑你的mysqld.cnf文件,例如:

vim /etc/mysql/mysql.conf.d/mysqld.cnf

Then, add in the [mysqld] part, the following :

然后,在 [mysqld] 部分添加以下内容:

plugin-load-add=validate_password.so
validate_password_policy=LOW

Basically, if you edit your default, it will looks like :

基本上,如果您编辑默认值,它将如下所示:

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
plugin-load-add=validate_password.so
validate_password_policy=LOW

Then, you can restart:

然后,您可以重新启动:

systemctl restart mysql

If you forget the plugin-load-add=validate_password.sopart, you will it an error at restart.

如果您忘记了该plugin-load-add=validate_password.so部件,则在重新启动时会出现错误。

Enjoy !

享受 !