1.vi /etc/my.cnf
2.在[mysqld]的段中加上一句:skip-grant-tables 保存并且退出。
3.service mysqld restart
4.mysql -uroot -p 回车
4.1 use mysql
5. UPDATE user SET Password = password ( '新密码' ) WHERE User = 'root' ;
6. flush privileges ;
7.quit;
8.vi /etc/my.cnf
9.去掉skip-grant-tables 保存并且退出
10.service mysqld restart