0%

Windows安装mysql8.0.11

准备

Mysql8.0.11下载: 官方下载
环境:Windows 7/Windows 10

安装

  1. 解压zip包到安装目录
    比如我的目录为:D:\mysql-8.0.11-winx64
  2. 配置文件
    在根目录下新建data文件夹(data文件夹必须为空),并在D:\mysql-8.0.11-winx64添加my.ini文件,写入基本配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = D:\mysql-8.0.11-winx64
datadir = D:\mysql-8.0.11-winx64\data
port = 3306
# server_id = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

character-set-server = utf8mb4

performance_schema_max_table_instances = 600
table_definition_cache = 400
table_open_cache = 256

[mysql]
default-character-set = utf8mb4

[client]
default-character-set = utf8mb4

注意修改上述配置文件中basedirdatadir目录。

  1. 添加环境变量
    D:\mysql-8.0.11-winx64\bin添加到系统Path中,注意必须为系统Path中,用户Path不可行。

  2. 初始化数据库
    mysqld --initialize --console
    执行完成后,会打印初始密码
    pic

  3. 安装服务
    以管理员身份执行命令mysqld --install mysqld
    之后可以通过net start mysqld启动mysql服务,net stop mysqld关闭mysql服务。
    pic

更改密码

在Mysql命令中执行
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
将密码改为123456.

速度测试

官方说MySQL8比5快两倍。

参考:https://blog.csdn.net/zwj1030711290/article/details/80039780