MYSQL设置完root初始密码登录问题
MYSQL设置完root初始密码登录问题
概要:
环境:windows、mysql-8.0.17-winx64
问题:设置初始密码时,因操作有误给root用户设置了个初始密码,忘记密码。
- 使用管理员启动windows命令窗口,停掉服务(net stop mysql);
2.跳过验证密码的mysql(mysqld --console --skip-grant-tables --shared-memory )。
-
重新以管理员方式启动一个windows命令窗口
1)、mysql -u root -p (无密码直接回车登录)
2)、select host, user, authentication_string, plugin from user;(查看当前用户信息)
3)、如果用户已经设置了密码了,要先设置为空:
use mysql;
update user set authentication_string=’’ where user=‘root’;
flush privileges;
4)、重新设置root的密码
use mysql;
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘你的密码’;(mysql_native_password 是因为我用Navicat连接时候提示:不支持caching_sha2_password)
flush privileges;
5)、退出,exit,密码修改完成。 -
启动服务(net start mysql)
-
验证下,Navicat验证下