(通用之日常)Win10中MySQL8忘记密码、修改密码
最新推荐文章于 2023-05-18 09:52:29 发布
cmd
,“以管理员身份运行”net stop mysql
,目的是停止mysql服务(也可以在“服务”中手动停止)mysqld --console --skip-grant-tables --shared-memory
mysql -u root -p
并回车show databases;
查看所有数据库,输入use mysql
切换到mysql库update mysql.user set authentication_string='' where user='root';
目的是将root密码置空(可能会疑惑为什么不直接设置密码?后面会解释)select host,user,authentication_string from mysql.user;
查看root密码已经置空net start mysql
启动mysql服务,再切换到bin目录下,接着输入mysql -u root -p
并回车use mysql;
切换至mysql库,再输入select user,host from user;
查看user的host值,最后根据host值输入alter user 'root'@'localhost' identified with mysql_native_password by '123456';
将设置密码为123456