mysql5.7登录提示MySQL 'root'@'::1'无法登录(windows)

当在Windows上遇到MySQL 5.7 'root'@'::1' 登录失败时,可以通过修改my.ini配置文件跳过密码验证,然后使用UPDATE语句更新root用户的密码。在my.ini中添加'skip-grant-tables',重启MySQL,再用UPDATE命令设置新密码,最后恢复配置并刷新权限。
摘要由CSDN通过智能技术生成

1.本地的hosts无法进行localhost及127.0.0.1映射

2.mysql服务端需要修改root的密码及host(忘记密码)

在my.ini中编辑增加一行添加如下内容:

skip-grant-tables       #用来跳过密码验证的过程

保存并退出,然后再启动mysql数据库

用UPDATE直接编辑user表 
首先登录MySQL。

 C:\Users\Administrator>mysql -u root -p   -------两次回车后进入mysql5.7
mysql> use mysql; 
mysql> update user set authentication_string=password("123456") where user='root';        #其中的"123456"是你需要修改的密码

mysql> flush privileges; 

mysql> grant all privileges on *.* to root@'%' identified by '123456' with grant option;

执行时会提示报错信息如下:

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement    #没关系不用理会它,继续执行flush privileges;

mysql>   flush privileges; 

mys

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值