How do I turn off the mysql password validation?

后端 未结 13 1252
傲寒
傲寒 2021-01-29 17:34

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.

I would l

相关标签:
13条回答
  • 2021-01-29 17:52

    If you want to make exceptions, you can apply the following "hack". It requires a user with DELETE and INSERT privilege for mysql.plugin system table.

    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

    0 讨论(0)
  • 2021-01-29 17:52

    I was having a problem on Ubuntu 18.04 on Mysql. When I needed to create a new user, the policy was always high.

    The way I figured out how to disable, for future colleagues who come to investigate, was set to low.

    Login to the mysql server as root

    mysql -h localhost -u root -p
    

    Set the new type of validation

    SET GLOBAL validate_password_policy=0; //For Low
    

    Restart mysql

    sudo service mysql restart
    
    0 讨论(0)
  • 2021-01-29 18:02

    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.

    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:

    skip-validate_password=1
    

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

    0 讨论(0)
  • 2021-01-29 18:05

    For mysql 8.0 the command to disable password validation component is:

    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 change the 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
    
    0 讨论(0)
  • 2021-01-29 18:06

    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';

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

    0 讨论(0)
  • 2021-01-29 18:06

    Uninstall:

    mysql> uninstall plugin validate_password;
    

    An uninstalled plugin is not displayed by 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.

    0 讨论(0)
提交回复
热议问题