windows 下 mysql设置初始密码

本文介绍了一种在忘记MySQL root密码后重新设置的方法。通过修改my.ini配置文件跳过权限表,然后登录数据库更新root用户的密码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.先在安装目录找到my.ini配置文件,打开配置文件,找到[mysqld]一行,在下面添加skip-grant-tables后保存该文件,重新启mysql动服务。

 

2.执行 mysql -u root -p    密码为空,直接回车;

usemysql

mysql>update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost';

 mysql>Flush privileges;

其中newpassword为root的新密码。

(可能先前的版本密码的抬头是password,5.7.11是 authentication_string,可以select * from user,查看一下)

(老版本)update user set password=password("123456") where user="root";

(5.7.11)update user set authentication_string=password("123456") where user="root";


3.将刚才my.ini配置文件添加的那一行去掉,重启mysql。

 

转载于:https://www.cnblogs.com/zhangxiangdong/p/8986152.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值