1,MySQL :: Begin Your Download 下载 mysql8解压版
2,解压到到本地目录 如:F:\tools\mysql-8.0.28-winx64
3,在F:\tools\mysql-8.0.28-winx64 中 新建my.ini:
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录,一定要与上面的安装路径保持一致
basedir=F:\\tools\\mysql-8.0.28-winx64
# 设置mysql数据库的数据的存放目录,自动生成,无需手动创建,当然也可以放在其他地方
datadir=F:\\tools\\mysql-8.0.28-winx64\\data
# 允许最大连接数
max_connections=50
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口,不建议修改,这是公认端口号
port=3306
default-character-set=utf8mb4
4,然后进入cmd 进入bin目录:
mysqld --initialize --console
F:\tools\mysql-8.0.28-winx64\bin>mysqld --initialize --console
2022-03-19T08:04:24.510222Z 0 [Warning] [MY-010918] [Server] 'default_authentica
tion_plugin' is deprecated and will be removed in a future release. Please use a
uthentication_policy instead.
2022-03-19T08:04:24.524223Z 0 [System] [MY-013169] [Server] F:\tools\mysql-8.0.2
8-winx64\bin\mysqld.exe (mysqld 8.0.28) initializing of server in progress as pr
ocess 2072
2022-03-19T08:04:40.351128Z 1 [System] [MY-013576] [InnoDB] InnoDB initializatio
n has started.
2022-03-19T08:05:03.155433Z 1 [System] [MY-013577] [InnoDB] InnoDB initializatio
n has ended.
2022-03-19T08:06:18.773758Z 6 [Note] [MY-010454] [Server] A temporary password i
s generated for root@localhost: nWodPc(xK6X%
nWodPc(xK6X% 为生成的初始密码,需要记住这个密码,后续登录以及修改密码需要用到。复制密码先保存起来!!!
出现以下错误,这是由于缺少微软的一些运行所需的库,点击这里[5iju]下载,安装后重新执行上面一步。
5,安装服务,启动,停止。cmd 在bin目录下执行:
F:\tools\mysql-8.0.28-winx64\bin>mysqld --install
Service successfully installed.
在mysql的bin目录下面执行: mysqld --install
报错信息如下:
Install/Remove of the Service Denied
解决办法:
打开cmd.exe程序的时候选择“用管理员身份打开”。
F:\tools\mysql-8.0.28-winx64\bin>net start mysql
MySQL 服务正在启动 ....
MySQL 服务已经启动成功。
F:\tools\mysql-8.0.28-winx64\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
6,修改密码,将密码更新为 123456
F:\tools\mysql-8.0.28-winx64\bin>mysql -u root -pnWodPc(xK6X%
mysql: [Warning] Using a password on the command line interface can be
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.18 sec)
安装完成