Search the MySQL manual:

4.1.3.1 Running Multiple Servers on Windows

You can run multiple servers on Windows by starting them manually from the command line, each with appropriate operating parameters. On Windows NT-based systems, you also have the option of installing several servers as services and running them that way. General instructions for running MySQL servers from the command line or as services are given in section 2.6.1 Windows Notes. This section describes how to make sure you start each server with different values for those startup options that must be unique per server, such as the data directory. (These options are described in section 4.1.3 Running Multiple MySQL Servers on the Same Machine.)

Starting Multiple Windows Servers at the Command Line

To start multiple servers manually from the command line, you can specify the appropriate options on the command line or in an option file. It's more convenient to place the options in an option file, but it's necessary to make sure that each server gets its own set of options. To do this, create an option file for each server and tell the server the filename with a --defaults-file option when you run it.

Suppose you want to run mysqld on port 3307 with a data directory of `C:\mydata1', and mysqld-max on port 3308 with a data directory of `C:\mydata2'. To accomplish this, create two option files. For example, create one file `C:\my-opts1.cnf' that looks like this:

[mysqld]
datadir = C:/mydata1
port = 3307

Create a second file `C:\my-opts2.cnf' that looks like this:

[mysqld]
datadir = C:/mydata2
port = 3308

Then start each server with its own option file:

shell> mysqld --defaults-file=C:\my-opts1.cnf
shell> mysqld-max --defaults-file=C:\my-opts2.cnf

(On NT, the servers will start in the foreground, so you'll need to issue those two commands in separate console windows.)

To shut down the servers, you must connect to the appropriate port number:

shell> mysqladmin --port=3307 shutdown
shell> mysqladmin --port=3308 shutdown

If you want to allow named pipe connections in addition to TCP/IP connections, use the mysqld-nt or mysqld-max-nt servers and specify options that enable the named pipe and specify its name. (Each server must have a unique pipe name.) For example, the `C:\my-opts1.cnf' file might be written like this:

[mysqld]
datadir = C:/mydata1
port = 3307
enable-named-pipe
socket = mypipe1

Then start the server this way:

shell> mysqld-nt --defaults-file=C:\my-opts1.cnf

`C:\my-opts2.cnf' would be modified similarly.

Starting Multiple Windows Servers as Services

On NT-based systems, you can install multiple servers as services. (This is possible as of MySQL 4.0.2.) In this case, you must make sure that each server uses a different service name in addition to all the other parameters that must be unique per server.

For the following instructions, assume that you want to run mysqld-nt servers from two different versions of MySQL that are installed at `C:\mysql-4.0.8' and `C:\mysql-4.0.14', respectively. (This might be the case if you're running 4.0.8 as your production server, but want to test 4.0.14 before upgrading to it.)

The following principles are relevant when installing a MySQL service with the --install (or --install-manual) option:

These principles give you several ways to set up multiple services. The following instructions describe some examples. Before trying any of them, be sure you shut down and remove any existing MySQL services first.

To remove multiple services, use mysqld --remove for each one, specifying a service name following the --remove option if the service to remove has a name different than the default.

User Comments

Add your own comment.