第一步:官方下载 mysql-5.7.32-winx64.zip 压缩包;
第二步:解压文件,我是放到了D盘下,解压后两个实例的路径如下,
D:\Program Files\mysql-5.7.32-V1
D:\Program Files\mysql-5.7.32-V2
第三步:安装实例1
1. 根目录下创建配置文件my.ini,主要为标红部分
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
#skip_grant_tables
# 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:/Program Files/mysql-5.7.32-V1
datadir = D:/Program Files/mysql-5.7.32-V1/data
port = 3307
server_id = MYSQL57V1
character_set_server=utf8
default-storage-engine=INNODB
max_connections=200
# 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
2. 打开命令行,以管理员方式运行,到实例1目录的bin文件夹下
D:\Program Files\mysql-5.7.32-V1\bin,
执行mysqld install MySql57V1 --defaults-file="D:\Program Files\mysql-5.7.32-V1\my-default.ini",初始化data目录;
再执行mysqld --defaults-file="D:\Program Files\mysql-5.7.32-V2\my-default.ini" --initialize-insecure --explicit_defaults_for_timestamp,创建为空的root账号
3. 如果以前安装过mysql,这是个坑,我在这里卡了老半天,需要到注册表查看对应服务的ImagePath的值是否为对应的目录,路径如下截图:
修改完毕后,启动服务net start MySql57V1
停止服务,net stop MySql57V1
4. 修改配置文件,打开安全模式,my.ini配置文件添加或打开这行配置
skip_grant_tables
5.回到控制台,执行mysql –u root –P 3307 –p,直接回车进入
6. 执行use mysql;
7. update user set authentication_string=password("123") where user="root";
显示:Query OK,1 rows affected(0.01 sec) Rows matched:1 Changed:1 Warnings:1
8. flush privileges;
显示:Query OK,0 rows affected (0.00 sec)
9. quit;
10.关闭安全模式
配置文件注释#skip_grant_tables
11.重启实例1服务
第四步,重复第三步步骤,安装实例2
注意目录要到自己的实例2目录下,我的是D:\Program Files\mysql-5.7.32-V2,
配置文件修改端口为3308,service-id=MySql57V2
mysqld install MySql57V2 --defaults-file="D:\Program Files\mysql-5.7.32-V1\my-default.ini"
两个实例安装完成