mysqld --initialize --insecure mysqld --defaults-file-E:\Mysql\mysql-8.0.27-winx64\my.ini --initialize --console mysqld --install [服务名] ###(服务名可以不加默认为mysql) mysqld --initialize --insecure --user=mysql net start mysql 2021-11-09T10:36:23.596187Z 6 [Note] [MY-010454] [Server] A temporary passwor d is generated for root@localhost: iKwjiw4LVV+x C:\Program Files\MySQL\MySQL Server 5.7\bin C:\Windows\system32 mysql -remove mysqld --initialize mysqld --initialize --insecure mysqld -install net start mysql update user set password=password("123") where user="root"; select * from mysql.user; select user,host from mysql.user; set password for root@localhost=password('root'); update user set authentication_string='' where user=‘root'; mysqladmin -u root -p password 123456 mysql8.0.解决方法忘记密码的完美解决方法 1.打开cmd窗口(最好以管理员身份打开) ,net stop mysql 停止mysql服务 2.开启跳过验证密码的mysql服 务mysqld --console --skip-grant-tables --shared-memory 3.打开一个新的cmd窗口,启动mysql服务mysql -u root -p 4.输入密码直接空格键跳过 5.将密码置空use mysqlupdate user set authentication_string='' where user=‘root'; exit 6. 关闭以步骤2打开的mysql服务(直接关掉窗口即可) 7.重新开启mysql服务,可以无密码登陆了 8.修改密码ALTER USER ‘root'@‘localhost' IDENTIFIED WITH mysql_native_password BY ‘111111'; flush privileges加入WITH mysql_native_password可以保证navicat连接不会出问题