Select Version:
选择 8.0.35
版本Other Downloads:
里面的 Windows (x86, 64-bit), ZIP Archive (mysql-8.0.35-winx64.zip)
后面的 Download
对压缩包下载No thanks, just start my download.
再点击保存之后进行下载MySQL
(对解压出来的文件夹进行改名,根据自己喜好去改就行,这里以改成 MySQL 为主)MySQL
的 安装目录
为 D:\Install\MySQL
(这个是自己压缩包解压的位置以及改名后的安装位置)MySQL
文件夹之后,新建一个名为 data
的文件夹(D:\Install\MySQL\data
是 MySQL
数据库的 数据存放目录
)MySQL
文件夹里新建一个文本文档(txt
文件)MySQL
安装目录
和数据存放目录
记得修改,就是上面提到的)[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\Install\MySQL
# 设置mysql数据库数据的存放目录,data文件夹自行创建
datadir=D:\Install\MySQL\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
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
my
,后缀改为 ini
,将其成为配置文件此电脑
,上面默认是选择 文件
,点击 查看
,在 显示/隐藏
一栏勾选 文件拓展名
,文件的后缀就会出现了windows
标,直接输入 cmd
,会搜索出一个 命令提示符
的应用,右击选择 以管理员身份运行
MySQL
的 bin
目录里面,路径是 D:\Install\MySQL\bin
D:
之后按 Enter
(回车)C:\Users\Administrator>D:
D:\>
cd D:\Install\MySQL\bin
之后按 Enter
(回车)即可D:\>cd D:\Install\MySQL\bin
D:\Install\MySQL\bin>
mysqld --initialize --console
之后按 Enter
(回车)查看密码D:\Install\MySQL\bin>mysqld --initialize --console
2024-01-03T07:30:28.143075Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2024-01-03T07:30:28.143102Z 0 [System] [MY-013169] [Server] D:\Install\MySQL\bin\mysqld.exe (mysqld 8.0.35) initializing of server in progress as process 21660
2024-01-03T07:30:28.162418Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-01-03T07:30:28.999724Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-01-03T07:30:31.717616Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: !_XJy.IXk7A;
2024-01-03T07:30:31.974746Z 6 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
D:\Install\MySQL\bin>
里面这一行 A temporary password is generated for root@localhost: !_XJy.IXk7A;
冒号后面就是密码,之后输入密码没法直接复制粘贴,随便找个地方记录一下,以便临时保存(!_XJy.IXk7A;)
mysqld --install mysql
之后按 Enter
(回车)安装 MySQL
服务D:\Install\MySQL\bin>mysqld --install mysql
Service successfully installed.
D:\Install\MySQL\bin>
net start mysql
之后按 Enter
(回车)启动 MySQL
服务D:\Install\MySQL\bin>net start mysql
mysql 服务正在启动 .
mysql 服务已经启动成功。
D:\Install\MySQL\bin>
mysql -u root -p
之后按 Enter
(回车)连接 MySQL
D:\Install\MySQL\bin>mysql -u root -p
Enter password:
将刚刚记录的密码手动输入,并按 Enter
(回车)
D:\Install\MySQL\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.35
Copyright (c) 2000, 2023, 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 BY ‘新的密码’;
(我这里用的新的密码是 123456),并按 Enter
(回车)mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.01 sec)
mysql>
此电脑
,选择 属性
,在右边 相关设置
一栏点击 高级系统设置
,之后点击 环境变量
系统变量
下面点击 新建
,变量名
填写 MYSQL_HOME
,变量值
填写 D:\Install\MySQL
,点击确定系统变量
中找到 变量
是 Path
,双击进入,点击 新建
,填写 %MYSQL_HOME%
之后按 Enter
(回车)新建
,填写 %MYSQL_HOME%\bin
之后按 Enter
(回车),然后一直点击 确定
退出即可windows
标,直接输入 cmd
,会搜索出一个 命令提示符
的应用,右击选择 以管理员身份运行
mysql --version
之后按 Enter
(回车)查看版本C:\Users\Administrator>mysql --version
mysql Ver 8.0.35 for Win64 on x86_64 (MySQL Community Server - GPL)
C:\Users\Administrator>
mysql -u root -p
之后按 Enter
(回车)连接 MySQL
C:\Users\Administrator>mysql -u root -p
Enter password:
123456
之后按 Enter
(回车)C:\Users\Administrator>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.35 MySQL Community Server - GPL
Copyright (c) 2000, 2023, 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>