MySQL Reference Manual for version 4.0.18.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.5 mysqld_multi, A Program for Managing Multiple MySQL Servers

mysqld_multi is meant for managing several mysqld processes that listen for connections on different Unix socket files and TCP/IP ports. It can start or stop servers, or report their current status.

The program searches for groups named [mysqld#] in `my.cnf' (or in the file named by the --config-file=... option on the command line). # can be any positive integer. This number is referred to in the following discussion as the option group number, or GNR. Group numbers distinquish option groups from one another and are used as arguments to mysqld_multi to specify which servers you want to start, stop, or obtain the status of. Options listed in these groups are the same as you would use in the usual [mysqld] group used for starting mysqld. (See, for example, 2.4.2.2 Starting and Stopping MySQL Automatically.) However, when using multiple servers it is necessary that each one use its own value for options such as the Unix socket file and TCP/IP port number. For more information on which options should be specified in a multiple-server environment, see 5.9 Running Multiple MySQL Servers on the Same Machine.

To invoke mysqld_multi, use the following syntax:

 
shell> mysqld_multi [OPTIONS] {start|stop|report} [GNR[,GNR]...]

start, stop, and report indicate the operation you want to perform. You can perform the operation on a single server or multiple servers, depending on the GNR list that follows the option name. If there is no list, mysqld_multi performs the operation for all servers in the option file.

Each GNR value represents an option group number or range of group numbers. The value should be the number at the end of the group name in the option file. For example, the GNR for a group named [mysqld17] is 17. To specify a range of numbers, separate the first and last numbers by a dash. The GNR value 10-13 represents groups [mysqld10] through [mysqld13]. Multiple groups or group ranges can be specified on the command line, separated by commas. There must be no whitespace characters (spaces or tabs) in the GNR list. (Anything after a whitespace character is ignored.)

This command starts a single server using option group [mysqld17]:

 
shell> mysqld_multi start 17

This command stops serveral servers, using option groups [mysql8] and [mysqld10] through [mysqld13]:

 
shell> mysqld_multi start 8,10-13

For an example of how you might set up an option file, use this command:

 
shell> mysqld_multi --example

mysqld_multi supports the following options:

--config-file=...
Specify the name of an alternative option file. This affects where mysqld_multi looks for [mysqld#] option groups. It does not affect where mysqld_multi reads its own options, which are always taken from the [mysqld_multi] group in the usual `my.cnf' file. Without this option, all options are read from the usual `my.cnf' file.
--example
Display an example option file.
--help
Print this help message and exit.
--log=...
Specify the name of the log file. If the file exists, log output is appended to it.
--mysqladmin=...
The mysqladmin binary to be used to stop servers.
--mysqld=...
The mysqld binary to be used. Note that you can specify mysqld_safe as the value for this option also. The options are passed to mysqld. Just make sure you have the directory where mysqld is located in your PATH environment variable setting or fix mysqld_safe.
--no-log
Print log information to stdout rather than to the log file. By default, output goes to the log file.
--password=...
The password of the MySQL account to use when invoking mysqladmin.
--tcp-ip
Connect to each MySQL server via the TCP/IP port instead of the Unix socket file. (If a socket file is missing, the server may still be running, but accessible only via the TCP/IP port.) By default, connections are made using the Unix socket file. This option affects stop and report operations.
--user=...
The username of the MySQL account to use when invoking mysqladmin.
--version
Print the version number and exit.

Some notes about mysqld_multi:

The following example shows how you might set up an option file for use with mysqld_multi. The first and fifth [mysqld#] group were intentionally left out from the example. You may have "gaps" in the option file. This gives you more flexibility. The order in which the mysqld programs are started or stopped depends on the order in which they appear in the option file.

 
# This file should probably be in your home dir (~/.my.cnf)
# or /etc/my.cnf
# Version 2.1 by Jani Tolonen

[mysqld_multi]
mysqld     = /usr/local/bin/mysqld_safe
mysqladmin = /usr/local/bin/mysqladmin
user       = multi_admin
password   = multipass

[mysqld2]
socket     = /tmp/mysql.sock2
port       = 3307
pid-file   = /usr/local/mysql/var2/hostname.pid2
datadir    = /usr/local/mysql/var2
language   = /usr/local/share/mysql/english
user       = john

[mysqld3]
socket     = /tmp/mysql.sock3
port       = 3308
pid-file   = /usr/local/mysql/var3/hostname.pid3
datadir    = /usr/local/mysql/var3
language   = /usr/local/share/mysql/swedish
user       = monty

[mysqld4]
socket     = /tmp/mysql.sock4
port       = 3309
pid-file   = /usr/local/mysql/var4/hostname.pid4
datadir    = /usr/local/mysql/var4
language   = /usr/local/share/mysql/estonia
user       = tonu

[mysqld6]
socket     = /tmp/mysql.sock6
port       = 3311
pid-file   = /usr/local/mysql/var6/hostname.pid6
datadir    = /usr/local/mysql/var6
language   = /usr/local/share/mysql/japanese
user       = jani

See section 4.3.2 Using Option Files.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by rdg (Feb 25 2004) using texi2html