系统环境:Red Hat Enterprise Linux Server 6
1.停止mysqld服务
[[email protected] huage]# service mysqld stop
2.以跳过授权的方式启动mysql
[[email protected] huage]# mysqld_safe --skip-grant-tables &
3.以root用户登录mysql
[[email protected] huage]# mysql -u root
4.进入mysql数据库
mysql> use mysql
5.更新mysql数据库中的user表的root的password字段
mysql> update user set password=PASSWORD("new_password") where User="root";
6.刷新权限,使其立即生效,之后退出mysql,并重新启动mysql
mysql> flush privileges;
mysql> quit
[[email protected] huage]# service mysqld restart
时间: 2024-10-12 14:00:08