Linux环境下重置MySQL数据库(root)密码

1.首先输入“service mysqld status”查看当前mysql服务状态,下图显示正在mysqld服务正在运行中
2.输入“killall -TERM mysqld”命令停止所有的mysqld进程。
3.输入“service mysqld stop”命令停止mysqld服务。
4.输入“mysqld_safe --skip-grant-tables &”命令以无密码方式进入MySQL安全模式。
5.输入“mysql -u root”并按回车键即可。
6.输入“use mysql;”挂载数据库。
7.输入"update user set password=password("New9ssw0rd") where user='root';"将Root密码修改为New9ssw0rd。
8.输入"flush privileges;"更新权限。
9.输入“quit”并按回车键退出。
10.输入"service mysqld restart"重启mysqld服务。
11.输入“mysql -u root -p”并按回车键提示输入密码。
12.输入新密码New9ssw0rd并按回车键,提示已经成功登录。
注意: 如果出现 ERROR 1054 (42S22): 即改密码时输入update user set password=password('root') where user='root'时提示ERROR 1054 (42S22): Unknown column 'password' in 'field list',原来是mysql数据库下已经没有password这个字段了,password字段改成了
authentication_string
所以更改语句替换为update user set authentication_string=password('root') where user='root' ;即可




更多推荐
所有评论(0)