windows 下 mysql设置初始密码

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。

猜你喜欢

转载自www.cnblogs.com/zhangxiangdong/p/8986152.html