正文
直奔主题
以root权限执行下述所有的命令
暂停mysql的服务:
service mysql stop
执行跳过tables的密码:
mysqld_safe --skip-grant-tables &
(其中&代表后台运行)
登录mysql并修改密码:
mysql
,之后切换mysql的表格:use mysql
- 根据不同的版本号修改对应密码:
如果是mysql8的版本:
update user set password=password("123456") where user='root'; flush privileges;
如果是mysql5的版本:
alter user 'root'@'localhost' identified with mysql_native_password by '123456'; flush privileges; alter user 'root'@'localhost' identified with mysql_native_password by '123456';
截图如下:
到此这篇关于linux出现sql密码被忘记的解决方法的文章就介绍到这了,更多相关linux sql密码被忘记内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!
发表评论