1、找到mysql的my.cnf文件
#vim /etc/my.cnf
2、在编辑文件my.cnf里面添加语句:skip-grant-table(跳过权限登录,输入任意密码即可进入)
skip-grant-table
然后重新开启 Mysql#service mysqld restart
3、mysql> alter user 'root'@'localhost'IDENTIFIED BY 'MyNewPass';(重置密码)
ERROR :The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
处理办法:
mysql> set global read_only=0;
(关掉新主库的只读属性)
flush privileges;
set global read_only=1;(读写属相)
flush privileges;
ERROR 1819 (HY000): Your password does notsatisfy the current policy requirements
mysql> alter user 'root'@'localhost'IDENTIFIED BY 'MyNewPass@123';
ERROR 1396 (HY000): Operation ALTER USERfailed for 'root'@'localhost'
mysql> alter user'root'@'%' IDENTIFIED BY 'MyNewPass@123';
【mysql8.0以上密码策略限制必须要大小写加数字特殊符号,我之前用mysqladmin,set,update,参考修改root密码的前人:http://www.cnblogs.com/liufei88866/p/5619215.html】
Query OK, 0 rows affected (0.05 sec)
退出,把Skip-grant-table语句删除,重新启动数据库
4、改好密码后再次进入#vim /etc/my.cnf 中把skip-grant-table 删除或者注释掉
5、重新进入 #service mysqld restart 验证密码是否修改成功