Table of Contents
Access denied ErrorsThis chapter covers topics that deal with administering a MySQL installation:
Configuring the server
Managing user accounts
Performing backups
The server log files
The query cache
The MySQL server, mysqld, is the main program that does most of the work in a MySQL installation. The server is accompanied by several related scripts that perform setup operations when you install MySQL or that assist you in starting and stopping the server. This section provides an overview of the server and related programs. The following sections provide more detailed information about each of these programs.
Each MySQL program takes many different options. Most programs
provide a --help option that you can use to get a
description of the program's different options. For example, try
mysqld --help.
You can override default option values for MySQL programs by specifying options on the command line or in an option file. Section 4.3, “Specifying Program Options”.
The following list briefly describes the MySQL server and server-related programs:
The SQL daemon (that is, the MySQL server). To use client programs, mysqld must be running, because clients gain access to databases by connecting to the server. See Section 5.2, “mysqld — The MySQL Server”.
A version of the server that includes additional features. See Section 5.3, “The mysqld-max Extended MySQL Server”.
A server startup script. mysqld_safe attempts to start mysqld-max if it exists, and mysqld otherwise. See Section 5.4.1, “mysqld_safe — MySQL Server Startup Script”.
A server startup script. This script is used on systems that use System V-style run directories containing scripts that start system services for particular run levels. It invokes mysqld_safe to start the MySQL server. See Section 5.4.2, “mysql.server — MySQL Server Startup Script”.
A server startup script that can start or stop multiple
servers installed on the system. See
Section 5.4.3, “mysqld_multi — Manage Multiple MySQL Servers”. As of MySQL 5.0.3 (Unix-like
systems) or 5.0.13 (Windows), an alternative to
mysqld_multi is
mysqlmanager, the MySQL Instance Manager.
See Section 5.5, “mysqlmanager — The MySQL Instance Manager”.
This script creates the MySQL database and initializes the grant tables with default privileges. It is usually executed only once, when first installing MySQL on a system. See Section 2.10.2, “Unix Post-Installation Procedures”.
This program is used after a MySQL upgrade operation. It updates the grant tables with any changes that have been made in newer versions of MySQL. See Section 5.6.1, “mysql_fix_privilege_tables — Upgrade MySQL System Tables”.
Note: As of MySQL 5.0.19, this program has been superseded by mysql_upgrade.
This program is used after a MySQL upgrade operation. It checks tables for incompatibilities and repairs them if necessary, and updates the grant tables with any changes that have been made in newer versions of MySQL. See Section 5.6.2, “mysql_upgrade — Check Tables for MySQL Upgrade”.
The MySQL Instance Manager, a program for monitoring and managing MySQL servers. See Section 5.5, “mysqlmanager — The MySQL Instance Manager”.
There are several other programs that are run on the server host:
mysqld is the MySQL server. The following discussion covers these MySQL server configuration topics:
Startup options that the server supports
Server system variables
Server status variables
How to set the server SQL mode
The server shutdown process
When you start the mysqld server, you can specify program options using any of the methods described in Section 4.3, “Specifying Program Options”. The most common methods are to provide options in an option file or on the command line. However, in most cases it is desirable to make sure that the server uses the same options each time it runs. The best way to ensure this is to list them in an option file. See Section 4.3.2, “Using Option Files”.
mysqld reads options from the
[mysqld] and [server]
groups. mysqld_safe reads options from the
[mysqld], [server],
[mysqld_safe], and
[safe_mysqld] groups.
mysql.server reads options from the
[mysqld] and
[mysql.server] groups.
An embedded MySQL server usually reads options from the
[server], [embedded],
and
[
groups, where xxxxx_SERVER]xxxxx is the name of
the application into which the server is embedded.
mysqld accepts many command options. For a brief summary, execute mysqld --help. To see the full list, use mysqld --verbose --help.
The following list shows some of the most common server options. Additional options are described in other sections:
Options that affect security: See Section 5.7.3, “Security-Related mysqld Options”.
SSL-related options: See Section 5.9.7.3, “SSL Command Options”.
Binary log control options: See Section 5.12.3, “The Binary Log”.
Replication-related options: See Section 6.8, “Replication Startup Options”.
Options specific to particular storage engines: See
Section 14.1.1, “MyISAM Startup Options”,
Section 14.5.3, “BDB Startup Options”,
Section 14.2.4, “InnoDB Startup Options and System Variables”, and
Section 15.6.5.1, “MySQL Cluster-Related Command Options for mysqld”.
You can also set the values of server system variables by using variable names as options, as described later in this section.
Display a short help message and exit. Use both the
--verbose and --help
options to see the full message.
This option controls whether user-defined functions that
have only an xxx symbol for the main
function can be loaded. By default, the option is off and
only UDFs that have at least one auxiliary symbol can be
loaded; this prevents attempts at loading functions from
shared object files other than those containing legitimate
UDFs. This option was added in version 5.0.3. See
Section 24.2.4.6, “User-Defined Function Security Precautions”.
Use standard (ANSI) SQL syntax instead of MySQL syntax.
For more precise control over the server SQL mode, use the
--sql-mode option instead. See
Section 1.9.3, “Running MySQL in ANSI Mode”, and
Section 5.2.5, “The Server SQL Mode”.
The path to the MySQL installation directory. All paths are usually resolved relative to this directory.
The IP address to bind to.
This option is used by the mysql_install_db script to create the MySQL privilege tables without having to start a full MySQL server.
The directory where character sets are installed. See Section 5.11.1, “The Character Set Used for Data and Sorting”.
--character-set-client-handshake
Don't ignore character set information sent by the client.
To ignore client information and use the default server
character set, use
--skip-character-set-client-handshake;
this makes MySQL behave like MySQL 4.0.
--character-set-filesystem=
charset_name
The filesystem character set. This option sets the
character_set_filesystem system
variable. It was added in MySQL 5.0.19.
--character-set-server=,
charset_name-C
charset_name
Use charset_name as the default
server character set. See
Section 5.11.1, “The Character Set Used for Data and Sorting”.
Put the mysqld server in a closed
environment during startup by using the
chroot() system call. This is a
recommended security measure. Note that use of this option
somewhat limits LOAD DATA INFILE and
SELECT ... INTO OUTFILE.
--collation-server=
collation_name
Use collation_name as the
default server collation. See
Section 5.11.1, “The Character Set Used for Data and Sorting”.
(Windows only.) Write error log messages to
stderr and stdout
even if --log-error is specified.
mysqld does not close the console
window if this option is used.
Write a core file if mysqld dies. For
some systems, you must also specify the
--core-file-size option to
mysqld_safe. See
Section 5.4.1, “mysqld_safe — MySQL Server Startup Script”. Note that on some systems,
such as Solaris, you do not get a core file if you are
also using the --user option.
The path to the data directory.
--debug[=,
debug_options]-#
[
debug_options]
If MySQL is configured with --with-debug,
you can use this option to get a trace file of what
mysqld is doing. The
debug_options string often is
'd:t:o,.
The default is file_name''d:t:i:o,mysqld.trace'.
See Section E.1.2, “Creating Trace Files”.
--default-character-set=
(DEPRECATED)
charset_name
Use charset_name as the default
character set. This option is deprecated in favor of
--character-set-server. See
Section 5.11.1, “The Character Set Used for Data and Sorting”.
--default-collation=
collation_name
Use collation_name as the
default collation. This option is deprecated in favor of
--collation-server. See
Section 5.11.1, “The Character Set Used for Data and Sorting”.
Set the default storage engine (table type) for tables. See Chapter 14, Storage Engines and Table Types.
This option is a synonym for
--default-storage-engine.
Set the default server time zone. This option sets the
global time_zone system variable. If
this option is not given, the default time zone is the
same as the system time zone (given by the value of the
system_time_zone system variable.
--delay-key-write[={OFF|ON|ALL}]
Specify how to use delayed key writes. Delayed key writing
causes key buffers not to be flushed between writes for
MyISAM tables. OFF
disables delayed key writes. ON enables
delayed key writes for those tables that were created with
the DELAY_KEY_WRITE option.
ALL delays key writes for all
MyISAM tables. See
Section 7.5.2, “Tuning Server Parameters”, and
Section 14.1.1, “MyISAM Startup Options”.
Note: If you set this
variable to ALL, you should not use
MyISAM tables from within another
program (such as another MySQL server or
myisamchk) when the tables are in use.
Doing so leads to index corruption.
Read the default DES keys from this file. These keys are
used by the DES_ENCRYPT() and
DES_DECRYPT() functions.
Enable support for named pipes. This option applies only on Windows NT, 2000, XP, and 2003 systems, and can be used only with the mysqld-nt and mysqld-max-nt servers that support named-pipe connections.
--exit-info[=,
flags]-T [
flags]
This is a bit mask of different flags that you can use for debugging the mysqld server. Do not use this option unless you know exactly what it does!
Enable external locking (system locking), which is
disabled by default as of MySQL 4.0. Note that if you use
this option on a system on which lockd
does not fully work (such as Linux), it is easy for
mysqld to deadlock. This option
previously was named --enable-locking.
Note: If you use this
option to enable updates to MyISAM
tables from many MySQL processes, you must ensure that the
following conditions are satisfied:
You should not use the query cache for queries that use tables that are updated by another process.
You should not use
--delay-key-write=ALL or
DELAY_KEY_WRITE=1 on any shared
tables.
The easiest way to ensure this is to always use
--external-locking together with
--delay-key-write=OFF and
--query-cache-size=0. (This is not done
by default because in many setups it is useful to have a
mixture of the preceding options.)
Flush (synchronize) all changes to disk after each SQL statement. Normally, MySQL does a write of all changes to disk only after each SQL statement and lets the operating system handle the synchronizing to disk. See Section A.4.2, “What to Do If MySQL Keeps Crashing”.
Read SQL statements from this file at startup. Each statement must be on a single line and should not include comments.
Adds consistency guarantees between the content of
InnoDB tables and the binary log. See
Section 5.12.3, “The Binary Log”. This option was removed in
MySQL 5.0.3, having been made obsolete by the introduction
of XA transaction support.
--innodb-
xxx
The InnoDB options are listed in
Section 14.2.4, “InnoDB Startup Options and System Variables”.
--language=
lang_name,
-L lang_name
Return client error messages in the given language.
lang_name can be given as the
language name or as the full pathname to the directory
where the language files are installed. See
Section 5.11.2, “Setting the Error Message Language”.
Some hardware/operating system architectures support memory pages greater than the default (usually 4KB). The actual implementation of this support depends on the underlying hardware and OS. Applications that perform a lot of memory accesses may obtain performance improvements by using large pages due to reduced Translation Lookaside Buffer (TLB) misses.
Currently, MySQL supports only the Linux implementation of large pages support (which is called HugeTLB in Linux). We have plans to extend this support to FreeBSD, Solaris and possibly other platforms.
Before large pages can be used on Linux, it is necessary
to configure the HugeTLB memory pool. For reference,
consult the hugetlbpage.txt file in
the Linux kernel source.
This option is disabled by default. It was added in MySQL 5.0.3.
--log[=,
file_name]-l [
file_name]
Log connections and SQL statements received from clients
to this file. See Section 5.12.2, “The General Query Log”. If you omit
the filename, MySQL uses
as the filename.
host_name.log
Enable binary logging. The server logs all statements that change data to the binary log, which is used for backup and replication. See Section 5.12.3, “The Binary Log”.
The option value, if given, is the basename for the log
sequence. The server creates binary log files in sequence
by adding a numeric suffix to the basename. It is
recommended that you specify a basename (see
Section A.8.1, “Open Issues in MySQL”, for the reason). Otherwise,
MySQL uses
as the basename.
host_name-bin
The index file for binary log filenames. See
Section 5.12.3, “The Binary Log”. If you omit the filename,
and if you didn't specify one with
--log-bin, MySQL uses
as the filename.
host_name-bin.index
--log-bin-trust-function-creators[={0|1}]
With no argument or an argument of 1, this option sets the
log_bin_trust_function_creators system
variable to 1. With an argument of 0, this option sets the
system variable to 0.
log_bin_trust_function_creators affects
how MySQL enforces restrictions on stored function
creation. See Section 17.4, “Binary Logging of Stored Routines and Triggers”.
This option was added in MySQL 5.0.16.
--log-bin-trust-routine-creators[={0|1}]
This is the old name for
--log-bin-trust-function-creators. Before
MySQL 5.0.16, it also applies to stored procedures, not
just stored functions and sets the
log_bin_trust_routine_creators system
variable. As of 5.0.16, this option is deprecated. It is
recognized for backward compatibility but its use results
in a warning.
This option was added in MySQL 5.0.6.
Log errors and startup messages to this file. See
Section 5.12.1, “The Error Log”. If you omit the filename,
MySQL uses
.
If the filename has no extension, the server adds an
extension of host_name.err.err.
Log all MyISAM changes to this file
(used only when debugging MyISAM).
--log-long-format
(DEPRECATED)
Log extra information to the update log, binary update
log, and slow query log, if they have been activated. For
example, the username and timestamp are logged for all
queries. This option is deprecated, as it now represents
the default logging behavior. (See the description for
--log-short-format.) The
--log-queries-not-using-indexes option is
available for the purpose of logging queries that do not
use indexes to the slow query log.
--log-queries-not-using-indexes
If you are using this option with
--log-slow-queries, queries that do not
use indexes are logged to the slow query log. See
Section 5.12.4, “The Slow Query Log”.
Log less information to the update log, binary update log, and slow query log, if they have been activated. For example, the username and timestamp are not logged for queries.
Log slow administrative statements such as
OPTIMIZE TABLE, ANALYZE
TABLE, and ALTER TABLE to the
slow query log.
--log-slow-queries[=
file_name]
Log all queries that have taken more than
long_query_time seconds to execute to
this file. See Section 5.12.4, “The Slow Query Log”. See the
descriptions of the --log-long-format and
--log-short-format options for details.
--log-warnings[=,
level]-W [
level]
Print out warnings such as Aborted
connection... to the error log. Enabling this
option is recommended, for example, if you use replication
(you get more information about what is happening, such as
messages about network failures and reconnections). This
option is enabled (1) by default, and the default
level value if omitted is 1. To
disable this option, use
--log-warnings=0. Aborted connections are
not logged to the error log unless the value is greater
than 1. See Section A.2.10, “Communication Errors and Aborted Connections”.
Give table-modifying operations
(INSERT, REPLACE,
DELETE, UPDATE)
lower priority than selects. This can also be done via
{INSERT | REPLACE | DELETE | UPDATE} LOW_PRIORITY
... to lower the priority of only one query, or
by SET LOW_PRIORITY_UPDATES=1 to change
the priority in one thread. See
Section 7.3.2, “Table Locking Issues”.
Lock the mysqld process in memory. This
works on systems such as Solaris that support the
mlockall() system call. This might help
if you have a problem where the operating system is
causing mysqld to swap on disk. Note
that use of this option requires that you run the server
as root, which is normally not a good
idea for security reasons. See
Section 5.7.5, “How to Run MySQL as a Normal User”.
--myisam-recover[=
option[,option]...]]
Set the MyISAM storage engine recovery
mode. The option value is any combination of the values of
DEFAULT, BACKUP,
FORCE, or QUICK. If
you specify multiple values, separate them by commas. You
can also use a value of "" to disable
this option. If this option is used, each time
mysqld opens a
MyISAM table, it checks whether the
table is marked as crashed or wasn't closed properly. (The
last option works only if you are running with external
locking disabled.) If this is the case,
mysqld runs a check on the table. If
the table was corrupted, mysqld
attempts to repair it.
The following options affect how the repair works:
| Option | Description |
DEFAULT | The same as not giving any option to --myisam-recover. |
BACKUP | If the data file was changed during recovery, save a backup of the
file as
. |
FORCE | Run recovery even if we would lose more than one row from the
.MYD file. |
QUICK | Don't check the rows in the table if there aren't any delete blocks. |
Before the server automatically repairs a table, it writes
a note about the repair to the error log. If you want to
be able to recover from most problems without user
intervention, you should use the options
BACKUP,FORCE. This forces a repair of a
table even if some rows would be deleted, but it keeps the
old data file as a backup so that you can later examine
what happened.
--ndb-connectstring=
connect_string
When using the NDB storage engine, it
is possible to point out the management server that
distributes the cluster configuration by setting the
connect string option. See
Section 15.4.4.2, “The MySQL Cluster connectstring”, for syntax.
If the binary includes support for the NDB
Cluster storage engine, this option enables the
engine, which is disabled by default. See
Chapter 15, MySQL Cluster.
Force the server to generate short (pre-4.1) password hashes for new passwords. This is useful for compatibility when the server must support older client programs. See Section 5.8.9, “Password Hashing as of MySQL 4.1”.
Only use one thread (for debugging under Linux). This option is available only if the server is built with debugging enabled. See Section E.1, “Debugging a MySQL Server”.
Change the number of file descriptors available to
mysqld. If this option is not set or is
set to 0, mysqld uses the value to
reserve file descriptors with
setrlimit(). If the value is 0,
mysqld reserves
max_connections×5 or
max_connections +
table_open_cache×2 files (whichever is
larger). You should try increasing this value if
mysqld gives you the error Too
many open files.
The pathname of the process ID file. This file is used by other programs such as mysqld_safe to determine the server's process ID.
The port number to use when listening for TCP/IP
connections. The port number must be 1024 or higher unless
the server is started by the root
system user.
On some systems, when the server is stopped, the TCP/IP port might not become available immediately. If the server is restarted quickly afterward, its attempt to reopen the port can fail. This option indicates how many seconds the server should wait for the TCP/IP port to become free if it cannot be opened. The default is not to wait. This option was added in MySQL 5.0.19.
Skip some optimization stages.
If this option is enabled, a user cannot create new MySQL
users by using the GRANT statement, if
the user doesn't have the INSERT
privilege for the mysql.user table or
any column in the table.
Disallow authentication by clients that attempt to use accounts that have old (pre-4.1) passwords.
Enable shared-memory connections by local clients. This option is available only on Windows.
--shared-memory-base-name=
name
The name of shared memory to use for shared-memory
connections. This option is available only on Windows. The
default name is MYSQL. The name is case
sensitive.
Disable the BDB storage engine. This
saves memory and might speed up some operations. Do not
use this option if you require BDB
tables.
Turn off the ability to select and insert at the same time
on MyISAM tables. (This is to be used
only if you think you have found a bug in this feature.)
See Section 7.3.3, “Concurrent Inserts”.
Do not use external locking (system locking). With
external locking disabled, you must shut down the server
to use myisamchk. (See
Section 1.4.3, “MySQL Stability”.) To avoid this requirement,
use the CHECK TABLE and REPAIR
TABLE statements to check and repair
MyISAM tables.
External locking has been disabled by default since MySQL 4.0.
This option causes the server not to use the privilege
system at all, which gives anyone with access to the
server unrestricted access to all
databases. You can cause a running server to
start using the grant tables again by executing
mysqladmin flush-privileges or
mysqladmin reload command from a system
shell, or by issuing a MySQL FLUSH
PRIVILEGES statement after connecting to the
server. This option also suppresses loading of
user-defined functions (UDFs).
Do not use the internal hostname cache for faster name-to-IP resolution. Instead, query the DNS server every time a client connects. See Section 7.5.6, “How MySQL Uses DNS”.
Disable the InnoDB storage engine. This
saves memory and disk space and might speed up some
operations. Do not use this option if you require
InnoDB tables.
Do not resolve hostnames when checking client connections.
Use only IP numbers. If you use this option, all
Host column values in the grant tables
must be IP numbers or localhost. See
Section 7.5.6, “How MySQL Uses DNS”.
Disable the NDB Cluster storage engine.
This is the default for binaries that were built with
NDB Cluster storage engine support; the
server allocates memory and other resources for this
storage engine only if the --ndbcluster
option is given explicitly. See
Section 15.4.3, “Quick Test Setup of MySQL Cluster”, for an example of
usage.
Don't listen for TCP/IP connections at all. All interaction with mysqld must be made via named pipes or shared memory (on Windows) or Unix socket files (on Unix). This option is highly recommended for systems where only local clients are allowed. See Section 7.5.6, “How MySQL Uses DNS”.
Options that begin with --ssl specify
whether to allow clients to connect via SSL and indicate
where to find SSL keys and certificates. See
Section 5.9.7.3, “SSL Command Options”.
Available on Windows NT-based systems only; instructs the MySQL server not to run as a service.
--symbolic-links,
--skip-symbolic-links
Enable or disable symbolic link support. This option has different effects on Windows and Unix:
On Windows, enabling symbolic links allows you to
establish a symbolic link to a database directory by
creating a
file that contains the path to the real directory. See
Section 7.6.1.3, “Using Symbolic Links for Databases on Windows”.
db_name.sym
On Unix, enabling symbolic links means that you can
link a MyISAM index file or data
file to another directory with the INDEX
DIRECTORY or DATA
DIRECTORY options of the CREATE
TABLE statement. If you delete or rename the
table, the files that its symbolic links point to also
are deleted or renamed. See
Section 7.6.1.2, “Using Symbolic Links for Tables on Unix”.
If MySQL is configured with
--with-debug=full, all MySQL programs
check for memory overruns during each memory allocation
and memory freeing operation. This checking is very slow,
so for the server you can avoid it when you don't need it
by using the --skip-safemalloc option.
With this option, the SHOW DATABASES
statement is allowed only to users who have the
SHOW DATABASES privilege, and the
statement displays all database names. Without this
option, SHOW DATABASES is allowed to
all users, but displays each database name only if the
user has the SHOW DATABASES privilege
or some privilege for the database. Note that
any global privilege is considered a
privilege for the database.
Don't write stack traces. This option is useful when you are running mysqld under a debugger. On some systems, you also must use this option to get a core file. See Section E.1, “Debugging a MySQL Server”.
Disable using thread priorities for faster response time.
On Unix, this option specifies the Unix socket file to use
when listening for local connections. The default value is
/tmp/mysql.sock. On Windows, the
option specifies the pipe name to use when listening for
local connections that use a named pipe. The default value
is MySQL (not case sensitive).
--sql-mode=
value[,value[,value...]]
Set the SQL mode. See Section 5.2.5, “The Server SQL Mode”.
As of MySQL 5.0.13, SYSDATE() by
default returns the time at which it executes, not the
time at which the statement in which it occurs begins
executing. This differs from the behavior of
NOW(). This option causes
SYSDATE() to be an alias for
NOW(). For information about the
implications for binary logging and replication, see the
description for SYSDATE() in
Section 12.5, “Date and Time Functions” and for
SET TIMESTAMP in
Section 13.5.3, “SET Syntax”.
This option was added in MySQL 5.0.20.
This option causes most temporary files created by the server to use a small set of names, rather than a unique name for each new file. This works around a problem in the Linux kernel dealing with creating many new files with different names. With the old behavior, Linux seems to “leak” memory, because it is being allocated to the directory entry cache rather than to the disk cache.
Sets the default transaction isolation level. The
level value can be
READ-UNCOMMITTED,
READ-COMMITTED,
REPEATABLE-READ, or
SERIALIZABLE. See
Section 13.4.6, “SET TRANSACTION Syntax”.
The path of the directory to use for creating temporary
files. It might be useful if your default
/tmp directory resides on a partition
that is too small to hold temporary tables. This option
accepts several paths that are used in round-robin
fashion. Paths should be separated by colon characters
(‘:’) on Unix and semicolon
characters (‘;’) on
Windows, NetWare, and OS/2. If the MySQL server is acting
as a replication slave, you should not set
--tmpdir to point to a directory on a
memory-based filesystem or to a directory that is cleared
when the server host restarts. For more information about
the storage location of temporary files, see
Section A.4.4, “Where MySQL Stores Temporary Files”. A replication slave
needs some of its temporary files to survive a machine
restart so that it can replicate temporary tables or
LOAD DATA INFILE operations. If files
in the temporary file directory are lost when the server
restarts, replication fails.
--user={,
user_name|user_id}-u
{
user_name|user_id}
Run the mysqld server as the user
having the name user_name or
the numeric user ID user_id.
(“User” in this context refers to a system
login account, not a MySQL user listed in the grant
tables.)
This option is mandatory when
starting mysqld as
root. The server changes its user ID
during its startup sequence, causing it to run as that
particular user rather than as root.
See Section 5.7.1, “General Security Guidelines”.
To avoid a possible security hole where a user adds a
--user=root option to a
my.cnf file (thus causing the server
to run as root),
mysqld uses only the first
--user option specified and produces a
warning if there are multiple --user
options. Options in /etc/my.cnf and
$MYSQL_HOME/my.cnf are processed
before command-line options, so it is recommended that you
put a --user option in
/etc/my.cnf and specify a value other
than root. The option in
/etc/my.cnf is found before any other
--user options, which ensures that the
server runs as a user other than root,
and that a warning results if any other
--user option is found.
Display version information and exit.
You can assign a value to a server system variable by using an
option of the form
--.
For example, var_name=value--key_buffer_size=32M sets the
key_buffer_size variable to a value of
32MB.
Note that when you assign a value to a variable, MySQL might automatically correct the value to stay within a given range, or adjust the value to the closest allowable value if only certain values are allowed.
If you want to restrict the maximum value to which a variable
can be set at runtime with SET, you can
define this by using the
--maximum-
command-line option.
var_name=value
It is also possible to set variables by using
--set-variable=
or var_name=value-O
syntax. This syntax is deprecated.
var_name=value
You can change the values of most system variables for a
running server with the SET statement. See
Section 13.5.3, “SET Syntax”.
Section 5.2.2, “Server System Variables”, provides a full description for all variables, and additional information for setting them at server startup and runtime. Section 7.5.2, “Tuning Server Parameters”, includes information on optimizing the server by tuning system variables.
The mysql server maintains many system
variables that indicate how it is configured. Each system
variable has a default value. System variables can be set at
server startup using options on the command line or in an
option file. Most of them can be changed dynamically while the
server is running by means of the SET
statement, which enables you to modify operation of the server
without having to stop and restart it. You can refer to system
variable values in expressions.
There are several ways to see the names and values of system variables:
To see the values that a server will use based on its compiled-in defaults and any option files that it reads, use this command:
mysqld --verbose --help
To see the values that a server will use based on its compiled-in defaults, ignoring the settings in any option files, use this command:
mysqld --no-defaults --verbose --help
To see the current values used by a running server, use
the SHOW VARIABLES statement.
This section provides a description of each system variable. Variables with no version indicated are present in all MySQL 5.0 releases. For historical information concerning their implementation, please see MySQL 3.23, 4.0, 4.1 Reference Manual.
For additional system variable information, see these sections:
Section 5.2.3, “Using System Variables”, discusses the syntax for setting and displaying system variable values.
Section 5.2.3.2, “Dynamic System Variables”, lists the variables that can be set at runtime.
Information on tuning sytem variables can be found in Section 7.5.2, “Tuning Server Parameters”.
Section 14.2.4, “InnoDB Startup Options and System Variables”, lists
InnoDB system variables.
Note: Some of the following variable
descriptions refer to “enabling” or
“disabling” a variable. These variables can be
enabled with the SET statement by setting
them to ON or 1, or
disabled by setting them to OFF or
0. However, to set such a variable on the
command line or in an option file, you must set it to
1 or 0; setting it to
ON or OFF will not work.
For example, on the command line,
--delay_key_write=1 works but
--delay_key_write=ON does not.
Values for buffer sizes, lengths, and stack sizes are given in bytes unless otherwise specified.
auto_increment_increment
auto_increment_increment and
auto_increment_offset are intended for
use with master-to-master replication, and can be used to
control the operation of AUTO_INCREMENT
columns. Both variables can be set globally or locally,
and each can assume an integer value between 1 and 65,535
inclusive. Setting the value of either of these two
variables to 0 causes its value to be set to 1 instead.
Attempting to set the value of either of these two
variables to an integer greater than 65,535 or less than 0
causes its value to be set to 65,535 instead. Attempting
to set the value of
auto_increment_increment or
auto_increment_offset to a non-integer
value gives rise to an error, and the actual value of the
variable remains unchanged.
These two variables affect
AUTO_INCREMENT column behavior as
follows:
auto_increment_increment controls
the interval between successive column values. For
example:
mysql>SHOW VARIABLES LIKE 'auto_inc%';+--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | auto_increment_increment | 1 | | auto_increment_offset | 1 | +--------------------------+-------+ 2 rows in set (0.00 sec) mysql>CREATE TABLE autoinc1->(col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);Query OK, 0 rows affected (0.04 sec) mysql>SET @@auto_increment_increment=10;Query OK, 0 rows affected (0.00 sec) mysql>SHOW VARIABLES LIKE 'auto_inc%';+--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | auto_increment_increment | 10 | | auto_increment_offset | 1 | +--------------------------+-------+ 2 rows in set (0.01 sec) mysql>INSERT INTO autoinc1 VALUES (NULL), (NULL), (NULL), (NULL);Query OK, 4 rows affected (0.00 sec) Records: 4 Duplicates: 0 Warnings: 0 mysql>SELECT col FROM autoinc1;+-----+ | col | +-----+ | 1 | | 11 | | 21 | | 31 | +-----+ 4 rows in set (0.00 sec)
(Note how SHOW VARIABLES is used
here to obtain the current values for these
variables.)
auto_increment_offset determines
the starting point for the
AUTO_INCREMENT column value.
Consider the following, assuming that these statements
are executed during the same session as the example
given in the description for
auto_increment_increment:
mysql>SET @@auto_increment_offset=5;Query OK, 0 rows affected (0.00 sec) mysql>SHOW VARIABLES LIKE 'auto_inc%';+--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | auto_increment_increment | 10 | | auto_increment_offset | 5 | +--------------------------+-------+ 2 rows in set (0.00 sec) mysql>CREATE TABLE autoinc2->(col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);Query OK, 0 rows affected (0.06 sec) mysql>INSERT INTO autoinc2 VALUES (NULL), (NULL), (NULL), (NULL);Query OK, 4 rows affected (0.00 sec) Records: 4 Duplicates: 0 Warnings: 0 mysql>SELECT col FROM autoinc2;+-----+ | col | +-----+ | 5 | | 15 | | 25 | | 35 | +-----+ 4 rows in set (0.02 sec)
If the value of
auto_increment_offset is greater
than that of
auto_increment_increment, the value
of auto_increment_offset is
ignored.
Should one or both of these variables be changed and then
new rows inserted into a table containing an
AUTO_INCREMENT column, the results may
seem counterintuitive because the series of
AUTO_INCREMENT values is calculated
without regard to any values already present in the
column, and the next value inserted is the least value in
the series that is greater than the maximum existing value
in the AUTO_INCREMENT column. In other
words, the series is calculated like so:
auto_increment_offset +
N ×
auto_increment_increment
where N is a positive integer
value in the series [1, 2, 3, ...]. For example:
mysql>SHOW VARIABLES LIKE 'auto_inc%';+--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | auto_increment_increment | 10 | | auto_increment_offset | 5 | +--------------------------+-------+ 2 rows in set (0.00 sec) mysql>SELECT col FROM autoinc1;+-----+ | col | +-----+ | 1 | | 11 | | 21 | | 31 | +-----+ 4 rows in set (0.00 sec) mysql>INSERT INTO autoinc1 VALUES (NULL), (NULL), (NULL), (NULL);Query OK, 4 rows affected (0.00 sec) Records: 4 Duplicates: 0 Warnings: 0 mysql>SELECT col FROM autoinc1;+-----+ | col | +-----+ | 1 | | 11 | | 21 | | 31 | | 35 | | 45 | | 55 | | 65 | +-----+ 8 rows in set (0.00 sec)
The values shown for
auto_increment_increment and
auto_increment_offset generate the
series 5 + N × 10, that
is, [5, 15, 25, 35, 45, ...]. The greatest value present
in the col column prior to the
INSERT is 31, and the next available
value in the AUTO_INCREMENT series is
35, so the inserted values for col
begin at that point and the results are as shown for the
SELECT query.
It is important to remember that it is not possible to
confine the effects of these two variables to a single
table, and thus they do not take the place of the
sequences offered by some other database management
systems; these variables control the behavior of all
AUTO_INCREMENT columns in
all tables on the MySQL server. If
one of these variables is set globally, its effects
persist until the global value is changed or overridden by
setting them locally, or until mysqld
is restarted. If set locally, the new value affects
AUTO_INCREMENT columns for all tables
into which new rows are inserted by the current user for
the duration of the session, unless the values are changed
during that session.
The auto_increment_increment variable
was added in MySQL 5.0.2. Its default value is 1. See
Section 6.13, “Auto-Increment in Multiple-Master Replication”.
auto_increment_offset
This variable was introduced in MySQL 5.0.2. Its default
value is 1. For particulars, see the description for
auto_increment_increment.
back_log
The number of outstanding connection requests MySQL can
have. This comes into play when the main MySQL thread gets
very many connection requests in a very short time. It
then takes some time (although very little) for the main
thread to check the connection and start a new thread. The
back_log value indicates how many
requests can be stacked during this short time before
MySQL momentarily stops answering new requests. You need
to increase this only if you expect a large number of
connections in a short period of time.
In other words, this value is the size of the listen queue
for incoming TCP/IP connections. Your operating system has
its own limit on the size of this queue. The manual page
for the Unix listen() system call
should have more details. Check your OS documentation for
the maximum value for this variable.
back_log cannot be set higher than your
operating system limit.
basedir
The MySQL installation base directory. This variable can
be set with the --basedir option.
bdb_cache_size
The size of the buffer that is allocated for caching
indexes and rows for BDB tables. If you
don't use BDB tables, you should start
mysqld with --skip-bdb
to not allocate memory for this cache.
bdb_home
The base directory for BDB tables. This
should be assigned the same value as the
datadir variable.
bdb_log_buffer_size
The size of the buffer that is allocated for caching
indexes and rows for BDB tables. If you
don't use BDB tables, you should set
this to 0 or start mysqld with
--skip-bdb to not allocate memory for
this cache.
bdb_logdir
The directory where the BDB storage
engine writes its log files. This variable can be set with
the --bdb-logdir option.
bdb_max_lock
The maximum number of locks that can be active for a
BDB table (10,000 by default). You
should increase this value if errors such as the following
occur when you perform long transactions or when
mysqld has to examine many rows to
calculate a query:
bdb: Lock table is out of available locks Got error 12 from ...
bdb_shared_data
This is ON if you are using
--bdb-shared-data to start Berkeley DB in
multi-process mode. (Do not use
DB_PRIVATE when initializing Berkeley
DB.)
bdb_tmpdir
The BDB temporary file directory.
binlog_cache_size
The size of the cache to hold the SQL statements for the
binary log during a transaction. A binary log cache is
allocated for each client if the server supports any
transactional storage engines and if the server has the
binary log enabled (--log-bin option). If
you often use large, multiple-statement transactions, you
can increase this cache size to get more performance. The
Binlog_cache_use and
Binlog_cache_disk_use status variables
can be useful for tuning the size of this variable. See
Section 5.12.3, “The Binary Log”.
bulk_insert_buffer_size
MyISAM uses a special tree-like cache
to make bulk inserts faster for INSERT ...
SELECT, INSERT ... VALUES (...), (...),
..., and LOAD DATA INFILE
when adding data to non-empty tables. This variable limits
the size of the cache tree in bytes per thread. Setting it
to 0 disables this optimization. The default value is 8MB.
character_set_client
The character set for statements that arrive from the client.
character_set_connection
The character set used for literals that do not have a character set introducer and for number-to-string conversion.
character_set_database
The character set used by the default database. The server
sets this variable whenever the default database changes.
If there is no default database, the variable has the same
value as character_set_server.
character_set_filesystem
The filesystem character set. This variable is used to
interpret string literals that refer to filenames, such as
in the LOAD DATA INFILE and
SELECT ... INTO OUTFILE statements and
the LOAD_FILE() function. Such
filenames are converted from
character_set_client to
character_set_filesystem before the
file opening attempt occurs. The default value is
binary, which means that no conversion
occurs. For systems on which multi-byte filenames are
allowed, a different value may be more appropriate. For
example, if the system represents filenames using UTF-8,
set character_set_filesytem to
'utf8'. This variable was added in
MySQL 5.0.19.
character_set_results
The character set used for returning query results to the client.
character_set_server
The server's default character set.
character_set_system
The character set used by the server for storing
identifiers. The value is always utf8.
character_sets_dir
The directory where character sets are installed.
collation_connection
The collation of the connection character set.
collation_database
The collation used by the default database. The server
sets this variable whenever the default database changes.
If there is no default database, the variable has the same
value as collation_server.
collation_server
The server's default collation.
completion_type
The transaction completion type:
If the value is 0 (the default),
COMMIT and
ROLLBACK are unaffected.
If the value is 1, COMMIT and
ROLLBACK are equivalent to
COMMIT AND CHAIN and
ROLLBACK AND CHAIN, respectively.
(A new transaction starts immediately with the same
isolation level as the just-terminated transaction.)
If the value is 2, COMMIT and
ROLLBACK are equivalent to
COMMIT RELEASE and
ROLLBACK RELEASE, respectively.
(The server disconnects after terminating the
transaction.)
This variable was added in MySQL 5.0.3
concurrent_insert
If ON (the default), MySQL allows
INSERT and SELECT
statements to run concurrently for
MyISAM tables that have no free blocks
in the middle. You can turn this option off by starting
mysqld with --safe or
--skip-new.
In MySQL 5.0.6, this variable was changed to take three integer values:
| Value | Description |
| 0 | Off |
| 1 | (Default) Enables concurrent insert for MyISAM tables
that don't have holes |
| 2 | Enables concurrent inserts for all MyISAM tables. If
table has a hole and is in use by another thread
the new row will be inserted at end of table. If
table is not in use, MySQL does a normal read lock
and inserts the new row into the hole. |
See also Section 7.3.3, “Concurrent Inserts”.
The number of seconds that the mysqld
server waits for a connect packet before responding with
Bad handshake.
datadir
The MySQL data directory. This variable can be set with
the --datadir option.
date_format
This variable is not implemented.
datetime_format
This variable is not implemented.
default_week_format
The default mode value to use for the
WEEK() function. See
Section 12.5, “Date and Time Functions”.
delay_key_write
This option applies only to MyISAM
tables. It can have one of the following values to affect
handling of the DELAY_KEY_WRITE table
option that can be used in CREATE TABLE
statements.
| Option | Description |
OFF | DELAY_KEY_WRITE is ignored. |
ON | MySQL honors any DELAY_KEY_WRITE option specified in
CREATE TABLE statements. This
is the default value. |
ALL | All new opened tables are treated as if they were created with the
DELAY_KEY_WRITE option enabled. |
If DELAY_KEY_WRITE is enabled for a
table, the key buffer is not flushed for the table on
every index update, but only when the table is closed.
This speeds up writes on keys a lot, but if you use this
feature, you should add automatic checking of all
MyISAM tables by starting the server
with the --myisam-