1.停止mysql服务

/etc/init.d/mysql stop

2.以skip-grant-tables参数启动mysql

/usr/local/mysql/bin/mysqld_safe –skip-grant-tables &

3.以空密码方式登录mysql

mysql -u root

4.重置root账号密码

update mysql.user set password=PASSWORD(‘newpassword’) where User=’root’;

5.刷新权限表

flush privileges;

6.退出mysq并重启

exit
/etc/init.d/mysql restart

发表评论

电子邮件地址不会被公开。 必填项已用*标注