1、修改配置文件:vim /etc/my.cnf
添加 skip-grant-tables #跳过数据库权限验证
保存退出:wq

2、重启mysql:service mysq restart #看你的服务名是哈 ?有的是mysqlid

3、免密登录:./mysql -u root #有的是不加 ./

进入数据库:use mysql
4、修改root密码:
update user set authentication_string = password('新密码'),password_last_changed=now() where user='root';
退出mysql数据库:quit
5、再次修改配置文件:vi /etc/my.cnf删除skip-grant-tables保存退出
重启mysql服务即可
1万+



被折叠的 条评论
为什么被折叠?



