Randolf's blog

MySQL Community Server 8.0.11 安装教程

2018-06-20
javascript
3分钟
422字

原文:MySQL 8.0 Windows zip 安装过程

首先下载 MySQL Community Server 8.0.11:https://dev.mysql.com/downloads/mysql/

接着配置:在安装根目录下添加 my.ini,比如我这里是:D:\Program Files\MySQL\my.ini,写入基本配置:

Terminal window
1
[mysqld]
2
# Remove leading # and set to the amount of RAM for the most important data
3
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
4
# innodb_buffer_pool_size = 128M
5
6
# Remove leading # to turn on a very important data integrity option: logging
7
# changes to the binary log between backups.
8
# log_bin
9
10
# These are commonly set, remove the # and set as required.
11
basedir = D:\Program Files\MySQL
12
datadir = D:\Program Files\MySQL\data
13
port = 3306
14
# server_id = .....
15
21 collapsed lines
16
17
# Remove leading # to set options mainly useful for reporting servers.
18
# The server defaults are faster for transactions and fast SELECTs.
19
# Adjust sizes as needed, experiment to find the optimal values.
20
# join_buffer_size = 128M
21
# sort_buffer_size = 2M
22
# read_rnd_buffer_size = 2M
23
24
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
25
26
character-set-server = utf8mb4
27
28
performance_schema_max_table_instances = 600
29
table_definition_cache = 400
30
table_open_cache = 256
31
32
[mysql]
33
default-character-set = utf8mb4
34
35
[client]
36
default-character-set = utf8mb4

接着初始化数据库:

Terminal window
1
mysqld --initialize --console

初始化的时候会输出日志:

Terminal window
1
2018-06-18T11:11:42.523486Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2
2018-06-18T11:11:42.535721Z 0 [System] [MY-013169] [Server] D:\Program Files\MySQL\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 13036
3
2018-06-18T11:12:14.577258Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Vwa5C>>pDVh)
4
2018-06-18T11:12:44.048693Z 0 [System] [MY-013170] [Server] D:\Program Files\MySQL\bin\mysqld.exe (mysqld 8.0.11) initializing of server has completed

其中 Vwa5C>>pDVh) 是初始密码。

然后安装服务:

Terminal window
1
mysqld --install

再启动服务:

Terminal window
1
net start mysql

最后登录 MySQL Community Server 修改密码:

Terminal window
1
# 先用初始密码登录
2
mysql -uroot -p

修改密码的时候要注意 MySQL Community Server版本之间的区别:

Terminal window
1
# MySQL 8.0.4 及以前
2
SET PASSWORD=PASSWORD(<password>);
3
4
# MySQL 8.0.4 以后
5
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY <password>;

这个区别是 MySQL 的密码认证插件的变化造成的,如果想默认使用 mysql_native_password 插件认证,可以在 my.ini 中配置 default_authentication_plugin 项:

Terminal window
1
[mysqld]
2
default_authentication_plugin=mysql_native_password
本文标题:MySQL Community Server 8.0.11 安装教程
文章作者:Randolf Zhang
发布时间:2018-06-20
Copyright 2025
站点地图