官网:MySQL :: Download MySQL Community Serverhttps://dev.mysql.com/downloads/mysql/
软件下载:MySQL :: Begin Your Downloadhttps://dev.mysql.com/downloads/file/?id=509736
在【E:\gitee20220401\mysql\mysql-8.0.28-winx64\mysql-8.0.28-winx64】里新增一个文件的my.ini
[mysqld]
basedir=E:\gitee20220401\\mysql\\mysql-8.0.28-winx64\\mysql-8.0.28-winx64
datadir=E:\gitee20220401\\mysql\\mysql-8.0.28-winx64\\mysql-8.0.28-winx64\\data
port=3306
[client]
# pipe=
# socket=MYSQL
port=3306
以管理员身份运行cmd
Microsoft Windows [版本 10.0.19044.1645]
(c) Microsoft Corporation。保留所有权利。C:\Windows\system32>cd E:\gitee20220401\mysql\mysql-8.0.28-winx64\mysql-8.0.28-winx64\bin
C:\Windows\system32>E:
E:\gitee20220401\mysql\mysql-8.0.28-winx64\mysql-8.0.28-winx64\bin>mysqld --initialize --console
2022-04-23T13:50:24.056182Z 0 [System] [MY-013169] [Server] E:\gitee20220401\mysql\mysql-8.0.28-winx64\mysql-8.0.28-winx64\bin\mysqld.exe (mysqld 8.0.28) initializing of server in progress as process 6828
2022-04-23T13:50:24.134839Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-04-23T13:50:33.693646Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-04-23T13:50:49.944444Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Bma=9pjfyt7/E:\gitee20220401\mysql\mysql-8.0.28-winx64\mysql-8.0.28-winx64\bin>mysqld install mysql8028
Service successfully installed.E:\gitee20220401\mysql\mysql-8.0.28-winx64\mysql-8.0.28-winx64\bin>net start mysql8028
mysql8028 服务正在启动 ...
mysql8028 服务已经启动成功。
E:\gitee20220401\mysql\mysql-8.0.28-winx64\mysql-8.0.28-winx64\bin>mysql -uroot -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28Copyright (c) 2000, 2022, 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> alter user'root'@'localhost' identified with mysql_native_password by 'root';
Query OK, 0 rows affected (0.10 sec)mysql>
测试用的MySQL 密码简单就好,生产环境记得改复杂一点就行了。