Running multiple MySQL instances on a single Windows machine might sound complex, but it’s a powerful setup that can help developers, testers, and database administrators manage isolated environments efficiently. Whether you’re testing different MySQL configurations, supporting multiple applications, or simulating a production-like setup on your local system, having more than one MySQL server running simultaneously can be a game-changer.
In this blog, we’ll walk you through a step-by-step guide to install and configure multiple MySQL Server instances on a Windows machine. We’ll cover how to set up separate data directories, assign unique ports, configure my.ini
files, and manage each instance as an independent Windows service. By the end, you’ll have a clean, organized multi-instance setup without needing multiple virtual machines or Docker containers.
Let’s get started!
We can install a different version of MySQL but cannot install multiple instances of the same version. To run multiple instances, the second instance of MySQL must install as a windows service. The installation must be performed manually using a command prompt. We are using mysqld to install MySQL, and the step-by-step process is following.
Let us perform the installation. Open the command prompt using an administrator account. To do that, Right-click on the Command prompt and select Run as Administrator.
First, create a new directory named MySQLDev on C:drive of the computer.
C:> mkdir MySQLDev
Copy the content of the MYSQL base directory to C:MySQLDev using the XCOPY command. If you have installed MySQL using default settings, the directory location is C:Program FilesMySQLMySQL Server XX. You can view the location of the base directory of the MySQL server from the Server Status screen of MySQL workbench.
C:> xcopy C:”Program Files”MySQL”MySQL Server XX″ C:MySQLDev /E /H
Once the subdirectories and files of the MySQL base directory are copied, copy the data directory and configuration file to the C:MySQLDev. The default location of the data directory is C:ProgramDataMySQLMySQL Server XXData.
XCOPY command to copy Data directory
C:> xcopy C:”ProgramData”MySQL”MySQL Server XX″data C:MySQLDevData /E /H
COPY Command to copy configuration file
C:>copy C:ProgramDataMySQL”MySQL Server XX″my.ini C:MySQLDev
Change the name of the configuration file named my.ini to MyDev.ini using the REN command.
C:> ren C:MySQLDevmy.ini MyDev.ini
Now, let us change the values of the configuration parameters in the MyDEV.ini file. We are making changes in the following parameters:
Save and close the configuration file.
To manually install MySQL as a Windows service, use mysqld command line utility. The command is the following:
C:> mysqld –install MySQLDEV –defaults-file=”C:MySQLDEVMyDEV.ini”
The service is installed successfully.
Once MySQL is installed as a windows service, let us start it.
To start the service, open the control panel open Administrative Tools Open Services. In the Services console, you can see the MySQLDEV service is installed. Right-click on it and click on Start.
If the configuration is made correctly, then the service will be started successfully. Alternatively, you can start the MySQLDEV service by running the following command.
Once the service is started you can connect to the new server by providing respective names and port details, additionally you change the root password for the instance if needed.
Setting up multiple MySQL instances on a single Windows machine might seem intimidating at first, but with the right structure and configuration, it becomes a straightforward process. By isolating each instance with its own data directory, port, configuration file, and service name, you gain the flexibility to test different environments, run parallel applications, or simulate real-world multi-database scenarios — all on one system.
Thanks you for your time–do try this out!!!
Lochan R