windows下安装多个mysql5.7.16免安装版版本数据库

本文详细介绍了如何在Windows环境下安装并配置两个MySQL5.7.16的免安装版本,包括解压安装文件、配置my.ini、创建数据文件夹、修改环境变量、安装和管理服务等步骤,确保每个数据库实例能独立运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



一:安装mysql5.7.16
1)解压mysql-5.7.16-winx64到指定文件夹下 ,路径为:E:\jee\mysql-5.7.16-winx64
2)拷贝my-default.ini,改名为my.ini
3)创建数据文件夹data到指定目录(一般情况下选择在mysql5.7.16文件夹下创建data文件夹)
4)在my.ini文件夹中添加mysql文件夹目录,数据文件目录,指定端口等。修改后全文件内容如下:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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]

# 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 = .....
# datadir = .....
# port = .....
# 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

# 以下内容手动添加
[client]
port=3306
default-character-set=utf8
[mysqld]
port=3306
character_set_server=utf8
#解压目录
basedir=E:\jee\mysql-5.7.16-winx64
#解压目录下data目录
datadir=E:\jee\mysql-5.7.16-winx64\data

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[WinMySQLAdmin]
E:\jee\mysql-5.7.16-winx64\bin\mysqld.exe
5)在环境变量中添加mysql启动路径:E:\jee\mysql-5.7.16-winx64\bin
6)右键cmd.exe,选择以管理员身份运行cmd.exe
7) 在dos窗口中执行如下命令,将mysql添加到windows服务中,方便日后手动启动、停止mysql。
mysqld --install MYSQL
8)在dos窗口中执行如下命令,创建数据库文件
mysqld --initialize-insecure --user=mysql
9)启动数据库,执行如下命令
net start mysql
10)关闭数据库,执行如下命令
net stop mysql
11)移除服务名,执行如下命令
mysqld --remove mysql

二、安装第二个myql数据库
1)拷贝源数据库文件夹,并更名,如:mysql5.7.15。路径为E:\jee\mysql-5.7.15-winx64
2)手动清空data目录,重新创建数据库(不执行此步骤,会造成数据库无法安装,启动等问题)
3)修改my.ini文件中mysql文件夹目录,数据文件目录,指定端口等。修改后全文件内容如下:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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]

# 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 = .....
# datadir = .....
# port = .....
# 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

# 以下内容手动添加
[client]
port=3307
default-character-set=utf8
[mysqld]
port=3307
character_set_server=utf8
#解压目录
basedir=E:\jee\mysql-5.7.15-winx64
#解压目录下data目录
datadir=E:\jee\mysql-5.7.15-winx64\data

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[WinMySQLAdmin]
E:\jee\mysql-5.7.15-winx64\bin\mysqld.exe
4)在环境变量中添加mysql启动路径:E:\jee\mysql-5.7.15-winx64\bin
5)右键cmd.exe,选择以管理员身份运行cmd.exe
6) 在dos窗口中执行如下命令,将mysql添加到windows服务中,方便日后手动启动、停止mysql。
mysqld --install MYSQL2 --defaults-file="E:\jee\mysql-5.7.15-winx64\bin\my.ini"
备注:此时需要添加--defaults-file参数,否则由于环境变量问题启动报错
7)打开注册表,找到HKEY_LOCAL_MACHINE\SYSTEM\services\MYSQL2,修改ImagePath参数,更正mysql服务相关路径。修改后内容如下:
E:\jee\mysql-5.7.15-winx64\bin\mysqld --defaults-file=E:\jee\mysql-5.7.15-winx64\\my.ini MySQL2
8)在dos窗口,进入到bin目(即:E:\jee\mysql-5.7.15-winx64\bin)录后,执行如下命令,创建数据库文件
mysqld --initialize-insecure --user=mysql
9)启动数据库,执行如下命令
net start mysql2
10)关闭数据库,执行如下命令
net stop mysql 2
11)移除服务名,执行如下命令
mysqld --remove mysql2
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值