Running Multiple MySQL Instances on One Machine
550
Section 4.5.4, “
mysqldump
— A Database Backup Program”
. In addition, the binary log is flushed
when its size reaches the value of the
max_binlog_size
[1472]
system variable.
A log-flushing operation does the following:
• If general query logging (
--log
[411]
) or slow query logging (
--log-slow-queries
[412]
) to a
log file is enabled, the server closes and reopens the general query log file or slow query log file.
• If binary logging (
--log-bin
[1467]
) is used, the server closes the current log file and opens a new
log file with the next sequence number.
• If the server was started with the
--log-error
[411]
option to cause the error log to be written to
a file, it renames the current log file with the suffix
-old
and creates a new empty error log file.
The server creates a new binary log file when you flush the logs. However, it just closes and reopens
the general and slow query log files. To cause new files to be created on Unix, rename the current log
files before flushing them. At flush time, the server opens new log files with the original names. For
example, if the general and slow query log files are named
mysql.log
and
mysql-slow.log
, you
can use a series of commands like this:
shell>
cd mysql-data-directory
shell>
mv mysql.log mysql.old
shell>
mv mysql-slow.log mysql-slow.old
shell>
mysqladmin flush-logs
On Windows, use
rename
rather than
mv
.
At this point, you can make a backup of
mysql.old
and
mysql-slow.old
and then remove them
from disk.
For older versions of MySQL, you cannot rename certain log files on Windows while the server has
them open. Before MySQL 5.0.17, this restriction applies to all log files. You must stop the server,
rename the file, then restart the server to create a new log file. From 5.0.18 on, the restriction applies
only to the error log file. To rename the error log file, a stop and restart can be avoided by flushing the
logs to cause the server to rename the current log file with the suffix
-old
and create a new empty
error log file.
To disable or enable general query logging for the current connection, set the session
sql_log_off
[494]
variable to
ON
or
OFF
.
5.3. Running Multiple MySQL Instances on One Machine
In some cases, you might want to run multiple instances of MySQL on a single machine. You might
want to test a new MySQL release while leaving an existing production setup undisturbed. Or you
might want to give different users access to different
mysqld
servers that they manage themselves.
(For example, you might be an Internet Service Provider that wants to provide independent MySQL
installations for different customers.)
It is possible to use a different MySQL server binary per instance, or use the same binary for multiple
instances, or any combination of the two approaches. For example, you might run a server from
MySQL 4.1 and one from MySQL 5.0, to see how different versions handle a given workload. Or
you might run multiple instances of the current production version, each managing a different set of
databases.
Whether or not you use distinct server binaries, each instance that you run must be configured with
unique values for several operating parameters. This eliminates the potential for conflict between
instances. Parameters can be set on the command line, in option files, or by setting environment
variables. See
Section 4.2.3, “Specifying Program Options”
. To see the values used by a given
instance, connect to it and execute a
SHOW VARIABLES
statement.
The primary resource managed by a MySQL instance is the data directory. Each instance should use
a different data directory, the location of which is specified using the
--datadir=path
[404]
option.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...