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.)
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.
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:
MySql
and the server reads options from the [mysqld]
group in
the standard option files.
--install
option, the server ignores the [mysqld]
option
group and instead reads options from the group that has the same name as the
service.
--defaults-file
option after the service name,
the server ignores the standard option files and reads options only from the
[mysqld]
group of the named file.
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.
[mysqld]
group for the server that is installed
under the default service name (MySql
). For other servers, use
a group name that is the same as the service name.
Suppose you want to run the 4.0.8 mysqld-nt
using the default service
name and the 4.0.14 mysqld-nt
using the service name mysqld2
.
In this case, you can use the [mysqld]
group for 4.0.8 and the
[mysqld2]
group for 4.0.14.
For example, you can set up `C:\my.cnf' like this:
# options for default service (MySql) [mysqld] basedir = C:/mysql-4.0.8 port = 3307 enable-named-pipe socket = mypipe1 # options for mysqld2 service [mysqld2] basedir = C:/mysql-4.0.14 port = 3308 enable-named-pipe socket = mypipe2Install the services like this:
shell> C:\mysql-4.0.8\bin\mysqld-nt --install shell> C:\mysql-4.0.14\bin\mysqld-nt --install mysqld2To start the services, use the services manager, or use
NET START
with the appropriate service names:
shell> NET START MySql shell> NET START mysqld2To stop the services, use the services manager, or use
NET STOP
with the same service names.
--defaults-file
when you install the services to tell each server
what file to use. In this case, each file should list options using a
[mysqld]
group.
With this approach, to specify options for the 4.0.8 mysqld-nt
,
create a file `C:\my-opts1.cnf' that looks like this:
[mysqld] basedir = C:/mysql-4.0.8 port = 3307 enable-named-pipe socket = mypipe1For the 4.0.14
mysqld-nt
, create a file
`C:\my-opts2.cnf' that looks like this:
[mysqld] basedir = C:/mysql-4.0.14 port = 3308 enable-named-pipe socket = mypipe2Install the services as follows (enter each command on a single line):
shell> C:\mysql-4.0.8\bin\mysqld-nt --install MySql --defaults-file=C:\my-opts1.cnf shell> C:\mysql-4.0.14\bin\mysqld-nt --install mysqld2 --defaults-file=C:\my-opts2.cnfTo use a
--defaults-file
option when you install a MySQL server as a
service, you must precede the option with the service name. That is why the
first command names the MySql
service explicitly, even though that is
the default service name.
Start and stop the services the same way as in the preceding example.
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.