1. 停止服务
$ service mysql stop
2. 修改配置文件
$ vim /etc/mysql/my.cnf
[mysqld]
skip-grant-tables # MySQL 启动时不启动 grant-tables
3. 重启服务
$ service mysql restart
4. 更改 root 密码
mysql> use mysql;
mysql> update user set authentication_string=PASSWORD("new_pass") where user='root';
5. 刷新权限
mysql> flush privileges ;