1.用root或者运行mysqld的用户登录系统;
2.利用service mysql stop将其结束;
3.使用--skip-grant-tables参数启动MySQL Server
shell>mysqld_safe --skip-grant-tables &
4.为 root@localhost设置新密码
shell>mysqladmin -u root
mysql>use mysql;
mysql> update mysql.user set password=password("123456") where user="root";
shell>flush-privileges password "newpassword"
5.重启MySQL Server