Mysql忘记密码或登录不上的解决方案

您所在的位置:网站首页 邮箱登录不进去怎么办呢 Mysql忘记密码或登录不上的解决方案

Mysql忘记密码或登录不上的解决方案

2024-07-08 08:10| 来源: 网络整理| 查看: 265

Mysql忘记密码或登录不上的解决方案

错误代码

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

文章目录 Mysql忘记密码或登录不上的解决方案1. 停止mysql服务2. 修改mysql配置文件3. 启动mysql服务4. 登录mysql5. 修改密码6. 删除skip-grant-tables

1. 停止mysql服务 # linux service mysqld stop # windows net stop mysql 2. 修改mysql配置文件 windows

到mysql的安装目录下找到my.ini, 在[mysqld]后添加skip-grant-tables 在这里插入图片描述

Linux

修改my.cnf 在[mysqld]后添加skip-grant-tables (跳过权限检查)

vi /etc/my.cnf

在这里插入图片描述

3. 启动mysql服务 # linux service mysqld start # windows net start mysql 4. 登录mysql mysql -uroot -p

此时mysql跳过密码检测,一直回车,即可登录成功。

5. 修改密码

先刷新权限表

flush privileges; alter user root@'localhost' identified by 'test@1234';

如果遇到以下错误

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

请查看 mysql简单密码修改

6. 删除skip-grant-tables

根据步骤2里的路径,找到对应的配置文件,将刚刚添加的skip-grant-tables,删掉或注释。

重启mysql服务

# linux service mysqld restart # windows net stop mysql net start mysql


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3