mysql8免安装版安装教程(windows)

1. 下载mysql

一般直接在mysql官网下载
下载好压缩包后,解压到想要安装的目录,首先创建一个存储数据的文件夹,我这里创建的是data文件夹,然后创建my.ini文件(ANSI编码格式,用记事本另存为就可以选择的到)

2. 配置mysql

my.ini文件内容(简单版的)

[mysqld]
# 设置3306端口
port=3306

# 自定义设置mysql的安装目录,即解压mysql压缩包的目录
basedir=C:\*\mysql-8.0.20-winx64

# 自定义设置mysql数据库的数据存放目录
datadir=C:\*\mysql-8.0.20-winx64\data

# 允许最大连接数
max_connections=200

# 允许连接失败的次数,这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10

# 服务端使用的字符集默认为UTF8
character-set-server=utf8

# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

# 默认使用“mysql_native_password”插件认证
#default_authentication_plugin=mysql_native_password

sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8

[client]
# 设置mysql客户端连接服务端时默认使用的端口和默认字符集
port=3306
default-character-set=utf8

3. 安装mysql

放好文件后,用管理员模式启动命令管理器,
进入目录中的bin目录

cd C:\*\mysql-8.0.20-winx64\bin

项目初始化

mysqld --defaults-file=C:\*\mysql-8.0.20-winx64\my.ini --initialize --console

初始化后代码信息,注意A temporary password is generated for root@localhost:信息后边的内容是密码,记得存储一下

020-07-06T03:41:58.369499Z 0 [System] [MY-013169] [Server] C:\*\mysql-8.0.20-winx64\bin\mysqld.exe (mysqld 8.0.20) initializing of server in progress as process 7156
2020-07-06T03:41:58.370842Z 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.
2020-07-06T03:41:58.380032Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-07-06T03:42:06.344953Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-07-06T03:42:17.728500Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: .oUxhh&_I7av

安装mysql服务,记得还是在当前bin目录下

mysqld --install

4. 安装完毕

记得去服务中启动Mysql服务

Q.E.D.


97年强迫症程序猿