Your password does not satisfy the current policy requirements

后端 未结 19 2516
眼角桃花
眼角桃花 2020-12-12 08:33

I want to create a new user in mysql with syntax:

create user \'demo\'@\'localhost\' identified by \'password\';

But it returns an error: <

相关标签:
19条回答
  • 2020-12-12 09:26

    For Laravel users having this issue with MySQL 8.0.x, add

    'modes'=> [
                 'ONLY_FULL_GROUP_BY',
                 'STRICT_TRANS_TABLES',
                 'NO_ZERO_IN_DATE',
                 'NO_ZERO_DATE',
                 'ERROR_FOR_DIVISION_BY_ZERO',
                 'NO_ENGINE_SUBSTITUTION',
                ],
    

    to your database.php file as below:

    // database.php
    
        'connections' => [
    
            'mysql' => [
                'driver'      => 'mysql',
                'host'        => env( 'DB_HOST', '127.0.0.1' ),
                'port'        => env( 'DB_PORT', '3306' ),
                'database'    => env( 'DB_DATABASE', 'forge' ),
                'username'    => env( 'DB_USERNAME', 'forge' ),
                'password'    => env( 'DB_PASSWORD', '' ),
                'unix_socket' => env( 'DB_SOCKET', '' ),
                'charset'     => 'utf8mb4',
                'collation'   => 'utf8mb4_unicode_ci',
                'prefix'      => '',
                'strict'      => true,
                'engine'      => null,
                'modes'       => [
                    'ONLY_FULL_GROUP_BY',
                    'STRICT_TRANS_TABLES',
                    'NO_ZERO_IN_DATE',
                    'NO_ZERO_DATE',
                    'ERROR_FOR_DIVISION_BY_ZERO',
                    'NO_ENGINE_SUBSTITUTION',
                ],
            ],
        ],
    

    It fixed it for me.

    0 讨论(0)
  • 2020-12-12 09:28

    If you don't care what the password policy is. You can set it to LOW by issuing mysql command below:

    mysql> SET GLOBAL validate_password.policy=LOW;
    
    0 讨论(0)
  • 2020-12-12 09:30

    SHOW VARIABLES LIKE 'validate_password%';

    mysql> SET GLOBAL validate_password.length = 6;

    mysql> SET GLOBAL validate_password.number_count = 0;

    mysql> SET GLOBAL validate_password.policy=LOW;

    SHOW VARIABLES LIKE 'validate_password%';

    0 讨论(0)
  • 2020-12-12 09:34

    didn't work for me on ubuntu fresh install of mysqld, had to add this: to /etc/mysql/mysql.conf.d/mysqld.cnf or the server wouldn't start (guess the plugin didn't load at the right time when I simply added it without the plugin-load-add directive)

    plugin-load-add=validate_password.so
    validate_password_policy=LOW
    validate_password_length=8
    validate_password_mixed_case_count=0
    validate_password_number_count=0
    validate_password_special_char_count=0
    
    0 讨论(0)
  • 2020-12-12 09:34

    There are some moments where finding a quick solution is great. But if you can avoid lowing passwords restrictions, it can keep you from having big headache in future.

    Next link is from the official documentation https://dev.mysql.com/doc/refman/5.6/en/validate-password.html, where they expose an example exactly like your one, and they solve it.

    The only one problem you have is that your password is not strong enough to satisfy the actual minimum policy (not recommended to remove). So you can try different passwords as you can see in the example.

    0 讨论(0)
  • 2020-12-12 09:35

    After running the command sudo mysql_secure_installation.

    1. Run sudo mysql to enter into the mysql prompt.
    2. Run this SELECT user,authentication_string,plugin,host FROM mysql.user; to check for user root to have as plugin auth_socket.
    3. Then do run uninstall plugin validate_password; to drop priviledges before running this ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';Be sure to change password to a strong password.

    NOTE: check out this link https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04 for more help

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