https://dev.mysql.com/downloads/mysql/
在D:\mysoft\mysql-8.0.35-winx64下新建my.ini文件
[mysqld]
#设置3306端口
port=3306
#设置mysql的安装目录
basedir=D:\mysoft\mysql-8.0.35-winx64
#设置mysql数据库的数据的存放目录
datadir=D:\mysoft\mysql-8.0.35-winx64\data
#允许最大连接数
max_connections=200
#允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
#服务端使用的字符集默认为UTF8
character-set-server=utf8
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
default_authentication_plugin=mysql_native_password
[mysql]
#设置mysql客户端默认字符集
default-character-set=utf8
[client]
#设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8
计算机》右键属性》高级系统设置》环境变量》系统变量》Path》编辑》新增
D:\mysoft\mysql-8.0.35-winx64\bin
以管理员省份运行
mysqld --initialize --user=mysql --console
C:\Windows\system32>mysqld --initialize --user=mysql --console
2023-10-26T06:30:22.173420Z 0 [System] [MY-013169] [Server] D:\mysoft\mysql-8.0.35-winx64\bin\mysqld.exe (mysqld 8.0.35) initializing of server in progress as process 35072
2023-10-26T06:30:22.174736Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2023-10-26T06:30:22.217952Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-10-26T06:30:22.770231Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-10-26T06:30:24.576404Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: A-ipL6.mQ7.p
注意复制随机密码
mysqld -install
C:\Windows\system32>mysqld -install
Service successfully installed.
net start mysql
mysql -u root -p
ALTER USER root@localhost IDENTIFIED BY 'root';