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。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM