mysql 5.6 mysql 5.7修改root密码 密码过期

1. 新建一个文档,文档内容为:

如果:MySQL 5.7.6 and later:则内容为:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

MySQL 5.7.5 and earlier:则为:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');

2. 再关闭mysql,service mysqld stop
启动mysql,增加init-file参数,
mysqld --init-file=/home/huang800336/doc/mysql-init.txt -u root

密码过期
mysql 内执行
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER
或者
SET GLOBAL default_password_lifetime = 0;  -- never 全局用户
或者
ALTER USER 'root'@'localhost' PASSWORD EXPIRE INTERVAL 90 DAY; -- 90 days


 转自:http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
http://dev.mysql.com/doc/refman/5.7/en/password-expiration-policy.html


你可能感兴趣的:(linux,mysql)