大网数据广告活动
服务器运维问答

How to install and start multiple MySQL instances on Windows 2012

· 52CE 我爱测

I just installed MySQL 5.7 on Windows 2012 VM. I am trying to create and run multiple instances but very frustrated that such a simple thing is not working. I installed MySQL in C:\Program Files\MySQL\MySQL Server 5.7 which is de…

问题原文

原帖链接 · Frank Martin · CC BY-SA 3.0

I just installed MySQL 5.7 on Windows 2012 VM. I am trying to create and run multiple instances but very frustrated that such a simple thing is not working.

I installed MySQL in C:\Program Files\MySQL\MySQL Server 5.7 which is default location and then I copied the folder and made another copy of it to create another instance (I suppose this is how it works?)

Both MySQL instances are shown in image below.

Server1

Server2

INI settings for both servers are given below:

Server1

server-id=1
log-bin="mysql-bin"
binlog-ignore-db=test
binlog-ignore-db=information_schema
replicate-ignore-db=test
replicate-ignore-db=information_schema
relay-log="mysql-relay-log"
auto-increment-increment = 2
auto-increment-offset = 1

Server2
server-id=2
log-bin="mysql-bin"
binlog-ignore-db=test
binlog-ignore-db=information_schema
replicate-ignore-db=test
replicate-ignore-db=information_schema
relay-log="mysql-relay-log"
auto-increment-increment = 2
auto-increment-offset = 2

I am running both servers by opening command prompt and typing following:
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld"
"C:\Program Files\MySQL\MySQL Server 5.7 - 2\bin\mysqld"

The command seems to run successfully as no error is shown but when I look at task manager to see if any mysql processes are running, I see none.

What am I doing wrong?

已采纳解答

原帖链接 · Frank Martin · CC BY-SA 3.0

The mistake I was doing was to copy whole MySQL installation folder. You don't need to copy this folder.

  • Simply create a new ini file for each instance that you want to run (examples given above) at any location for e.g. C:\MyInstances\my1.ini.
  • Then create a new folder for e.g. data1 in C:\MyInstances\data1 and copy mysql and information_schema databases in it. You will get these databases from data folder where MySQL is installed. On Windows 2012 (and probably other server OS) it typically is C:\ProgramData\MySQL
  • Then define the following in your ini file.

datadir=C:/MyInstances/data1

  1. Then run following command which will install MySQL as service. After services is created simply run the service.

MySqlpath\bin\mysqld --install mysqld1 --defaults-file=PATH_TO_YOUR_INI_FILE

Of course in each ini file, you have to define a different port number as mentioned by @Anthony Fornito.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-12-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。