网站建设知识
windows下安装多个mysql5.7.16免安装版版本数据库
2025-07-22 10:02  点击:0

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

一:安装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# dev.mysql/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=3306default-character-set=utf8[mysqld]port=3306character_set_server=utf8#解压目录basedir=E:\jee\mysql-5.7.16-winx64#解压目录下data目录datadir=E:\jee\mysql-5.7.16-winx64\datasql_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

# dev.mysql/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