mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'X2x.123456'; Query OK, 0 rows affected (0.02 sec) # 查看密码策略 mysql> SHOW VARIABLES LIKE 'validate_password%'; +--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | validate_password.check_user_name | ON | | validate_password.dictionary_file | | | validate_password.length | 8 | | validate_password.mixed_case_count | 1 | | validate_password.number_count | 1 | | validate_password.policy | MEDIUM | | validate_password.special_char_count | 1 | +--------------------------------------+--------+ 7 rows inset (0.01 sec) # 百度的错误方法 # mysql> set global validate_password_policy=LOW; # ERROR 1193 (HY000): Unknown system variable 'validate_password_policy' # 将策略改成低 mysql> set global validate_password.policy=LOW; Query OK, 0 rows affected (0.00 sec) # 把密码改成之前想要的 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; Query OK, 0 rows affected (0.02 sec)
远程设置
1 2 3 4 5 6
mysql> use mysql; mysql> update user set host='%'where user='root'; # 授权用户名的权限,赋予任何主机访问数据的权限 mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; mysql> alter user 'root'@'%' identified with mysql_native_password by '123456'; mysql> FLUSH PRIVILEGES;