在 windows 上,使用 noinstall ZIP Archives 安装
初始化数据路径
D:\msql\bin>mysqld --initialize --console
2026-03-11T13:30:35.902837Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2026-03-11T13:30:35.907178Z 0 [System] [MY-013169] [Server] D:\j\msql\bin\mysqld.exe (mysqld 9.6.0) initializing of server in progress as process 15248
2026-03-11T13:30:36.007499Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2026-03-11T13:30:39.853596Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2026-03-11T13:30:50.811123Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: M%d3efqf+oLV
2026-03-11T13:31:04.068876Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
D:\msql\bin>
从上面最后一行,可以看到:M%d3efqf+oLV 是随机产生的root用户下的密码.
安装服务及修改密码
D:\msql\bin>mysqld --install
Service successfully installed.
开启 MySQL server:在CMD D:\msql\bin 下,输入 net start mysql
D:\msql\bin>net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
D:\msql\bin>
登录服务: 先输入 mysql -uroot -p
然后输入密码: M%d3efqf+oLV
D:\msql\bin>mysql -uroot -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 9.6.0
Copyright (c) 2000, 2026, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'happy';
Query OK, 0 rows affected (0.03 sec)
mysql>
这样,初始数据路径时随机产生的密码 M%d3efqf+oLV 被修改为 happy。
可以输入quit
退出服务。以新密码 happy 登录服务:
先输入 mysql -uroot -p
然后输入新密码。