Mysql修改root密码
#查看数据库用户表;
SELECT * FROM mysql.user;
#查看用户root的字段,没有password字段时密码字段为authentication_string;
SELECT * FROM USER WHERE USER=‘root’;
#修改用户root的密码;
UPDATE mysql.user SET authentication_string =PASSWORD(‘root’) WHERE USER=‘root’;
#刷新权限,修改立即生效;
FLUSH PRIVILEGES;
#如果出现错误码:1819,Your password does not satisfy the current policy requirements
#则设置密码策略错误,则用以下命令查看密码格式策略要求;
#查看密码策略;
SHOW VARIABLES LIKE ‘validate_password%’;
#----------密码策略方式validate_password_policy取值说明start--------------
#0 or LOW Length #只检查长度;
#1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters #检查长度、数字、大小写、特殊字符;
#2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file #检查长度、数字、大小写、特殊字符字典文件。
#----------validate_password_policy取值说明end--------------
SET GLOBAL validate_password_check_user_name=OFF; #用户名检测,默认关闭;
SET GLOBAL validate_password_dictionary_file; #指定密码验证的文件路径;
SET GLOBAL validate_password_length=8; #密码最小长度;
SET GLOBAL validate_password_policy=MEDIUM; #密码策略方式;
SET GLOBAL validate_password_number_count=1 #至少包含数字个数;
SET GLOBAL validate_password_special_char_count=1; #至少包含特殊字符的个数;
SHOW VARIABLES LIKE ‘validate_password%’; #查看密码策略;