mysql -uroot -p mysql> ALTERUSER'root'@'localhost' IDENTIFIED BY'MyNewPass4!';
以后通过 update set 语句修改密码
1 2 3
use mysql; updateusersetpassword=PASSWORD('MyNewPass5!') whereuser='root'; flush privileges;
注意:mysql 5.7 默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 错误。测试环境可以临时设置:set global validate_password_policy=LOW;