MySQL5重置root密码

2014-11-24 18:29:49 · 作者: · 浏览: 0

设置用户名root 密码为root //上面刚设置好的密码


[root@localhost html]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: No)


无法修改密码



service mysqld stop

mysqld_safe --skip-grant-tables &
mysqld_safe --skip-grant-tables --skip-networking &
以上两种皆可


输入 mysql -uroot -p 回车进入


use mysq;

update user set password=PASSWORD("newpass")where user="root"; 更改密码为 newpass

flush privileges; 更新权限

quit 退出


service mysqld restart 重启数据库
mysql -uroot -p 新密码进入