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 is more convenient to place the options in an
option file, but it is 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 file name with a
--defaults-file
option when you
run it.
Suppose that you want to run mysqld on port
3307 with a data directory of C:\mydata1
,
and mysqld-debug on port 3308 with a data
directory of C:\mydata2
. (To do this, make
sure that before you start the servers, each data directory
exists and has its own copy of the mysql
database that contains the grant tables.) Then create two option
files. For example, create one file named
C:\my-opts1.cnf
that looks like this:
[mysqld] datadir = C:/mydata1 port = 3307
Create a second file named C:\my-opts2.cnf
that looks like this:
[mysqld] datadir = C:/mydata2 port = 3308
Then start each server with its own option file:
C:\>C:\mysql\bin\mysqld --defaults-file=C:\my-opts1.cnf
C:\>C:\mysql\bin\mysqld-debug --defaults-file=C:\my-opts2.cnf
Each server starts in the foreground (no new prompt appears until the server exits later), so you will need to issue those two commands in separate console windows.
To shut down the servers, you must connect to each using the appropriate port number:
C:\>C:\mysql\bin\mysqladmin --port=3307 shutdown
C:\>C:\mysql\bin\mysqladmin --port=3308 shutdown
Servers configured as just described allow clients to connect
over TCP/IP. If your version of Windows supports named pipes and
you also want to allow named-pipe connections, use the
mysqld-nt or mysqld-debug
server and specify options that enable the named pipe and
specify its name. Each server that supports named-pipe
connections must use 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:
C:\> C:\mysql\bin\mysqld-nt --defaults-file=C:\my-opts1.cnf
Modify C:\my-opts2.cnf
similarly for use by
the second server.
A similar procedure applies for servers that you want to support
shared-memory connections. Enable such connections with the
--shared-memory
option and
specify a unique shared-memory name for each server with the
--shared-memory-base-name
option.
User Comments
Also if you have MySQL installed as a service, open the registry editor (Start->run, type regedit) and navigate to
HKEY_LOCAL_MACHINE->System->CurrentControlSet->
Services(This may vary by Windows version. I'm using Windows XP)
Look for your MySQL service and click on that. On the right side of the registry editor you should see a line that says "ImagePath". Right click on that and press modify. At the end of the path type this:
--defaults-file=[PATH_TO_MY.INI]
Replace [PATH_TO_MY.INI] with the path to your configuration file. In the end it should look something like this:
C:\mysql\bin\mysqld --defaults-file=C:\mysql\lib\my4.0.ini
Repeat for all MySQL servers and when they start it will load the configuration file automatically
Add your own comment.