7.1.7 Server Command Options
MySQL 8.4 Reference Manual Including MySQL NDB Cluster 8.4
7.1.7 Server Command Options
When you start the mysqld server, you can specify program options using any of the methods described in Section 6.2.2, “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 6.2.2.2, “Using Option Files”. That section also describes option file format and syntax.
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.
mysqld accepts many command options. For a brief summary, execute this command:
mysqld --help
To see the full list, use this command:
mysqld --verbose --help
Some of the items in the list are actually system variables that
can be set at server startup. These can be displayed at runtime
using the SHOW VARIABLES statement.
Some items displayed by the preceding mysqld
command do not appear in SHOW
VARIABLES output; this is because they are options only
and not system variables.
The following list shows some of the most common server options. Additional options are described in other sections:
- Options that affect security: See Section 8.1.4, “Security-Related mysqld Options and Variables”.
- SSL-related options: See Command Options for Encrypted Connections.
- Binary log control options: See Section 7.4.4, “The Binary Log”.
- Replication-related options: See Section 19.1.6, “Replication and Binary Logging Options and Variables”.
- Options for loading plugins such as pluggable storage engines: See Section 7.6.1, “Installing and Uninstalling Plugins”.
- Options specific to particular storage engines: See Section 17.14, “InnoDB Startup Options and System Variables” and Section 18.2.1, “MyISAM Startup Options”.
Some options control the size of buffers or caches. For a given buffer, the server might need to allocate internal data structures. These structures typically are allocated from the total memory allocated to the buffer, and the amount of space required might be platform dependent. This means that when you assign a value to an option that controls a buffer size, the amount of space actually available might differ from the value assigned. In some cases, the amount might be less than the value assigned. It is also possible that the server adjusts a value upward. For example, if you assign a value of 0 to an option for which the minimal value is 1024, the server sets the value to 1024.
Values for buffer sizes, lengths, and stack sizes are given in bytes unless otherwise specified.
Some options take file name values. Unless otherwise specified,
the default file location is the data directory if the value is a
relative path name. To specify the location explicitly, use an
absolute path name. Suppose that the data directory is
/var/mysql/data. If a file-valued option is
given as a relative path name, it is located under
/var/mysql/data. If the value is an absolute
path name, its location is as given by the path name.
You can also set the values of server system variables at server
startup by using variable names as options. To assign a value to a
server system variable, use an option of the form
--var_name=value.
For example,
--sort_buffer_size=384M sets the
sort_buffer_size variable to a
value of 384MB.
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 permissible value if only certain values are permitted.
To restrict the maximum value to which a system variable can be
set at runtime with the
SET
statement, specify this maximum by using an option of the form
--maximum-var_name=value
at server startup.
You can change the values of most system variables at runtime with
the SET
statement. See Section 15.7.6.1, “SET Syntax for Variable Assignment”.
Section 7.1.8, “Server System Variables”, provides a full description for all variables, and additional information for setting them at server startup and runtime. For information on changing system variables, see Section 7.1.1, “Configuring the Server”.
--help,-?
| Command-Line Format | --help |
Display a short help message and exit. Use both the
--verbose and
--help options to see the full
message.
- --allow-suspicious-udfs
| Command-Line Format | --allow-suspicious-udfs[={OFF|ON}] |
| Type | Boolean |
| Default Value | OFF |
This option controls whether loadable functions that have only
an xxx symbol for the main function can be
loaded. By default, the option is off and only loadable
functions 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
functions. See Loadable Function Security Precautions.
- --ansi
| Command-Line Format | --ansi |
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.7, “MySQL Standards Compliance”, and
Section 7.1.11, “Server SQL Modes”.
- --basedir=dir_name,
-b
dir_name
| Command-Line Format | --basedir=dir_name |
| System Variable | basedir |
| Scope | Global |
| Dynamic | No |
SET_VAR Hint Applies |
No |
| Type | Directory name |
| Default Value | parent of mysqld installation directory |
The path to the MySQL installation directory. This option sets
the basedir system variable.
The server executable determines its own full path name at
startup and uses the parent of the directory in which it is
located as the default
basedir value. This in turn
enables the server to use that
basedir when searching for
server-related information such as the
share directory containing error
messages.
- --check-table-functions=value
| Command-Line Format | --check-table-functions=value |
| Type | Enumeration |
| Default Value | ABORT |
| Valid Values | WARN ABORT |
When performing an upgade of the server, we scan the data
dictionary for functions used in table constraints and other
expressions, including DEFAULT expressions,
partitioning expressions, and virtual columns. It is possible
that a change in the behavior of the function causes it to
raise an error in the new version of the server, where no such
error occurred before in which case the table cannot be
opened. This option provides a choice in how to handle such
problems, according to which of the two values shown here is
used:
WARN: Log a warning for each table that cannot be opened.ABORT: Also logs a warning; in addition, the upgrade is stopped. This is the default. For a sufficiently high value of--log-error-verbosity, it also logs a note with a streamlined table definition listing only those expressions that potentially contain SQL functions.
The default behaviour is to abort the upgrade, so that the
user can fix the issue using the older version of the server,
before upgrading to the newer one. Use WARN
to continue the upgrade in interactive mode while reporting
any issues.
The --check-table-functions option was
introduced in MySQL 8.4.5.
- --chroot=dir_name,
-r dir_name
| Command-Line Format | --chroot=dir_name |
| Type | Directory name |
Put the mysqld server in a closed
environment during startup by using the
chroot() system call. This is a recommended
security measure. Use of this option somewhat limits
LOAD DATA and
SELECT ... INTO
OUTFILE.
- --console
| Command-Line Format | --console |
| Platform Specific | Windows |
(Windows only.) Cause the default error log destination to be the console. This affects log sinks that base their own output destination on the default destination. See Section 7.4.2, “The Error Log”. mysqld does not close the console window if this option is used.
--console takes precedence over
--log-error if both are given.
- --core-file
| Command-Line Format | --core-file |
When this option is used, write a core file if
mysqld dies; no arguments are needed (or
accepted). The name and location of the core file is system
dependent. On Linux, a core file named
core.pid is
written to the current working directory of the process, which
for mysqld is the data directory.
pid represents the process ID of
the server process. On macOS, a core file named
core.pid is
written to the /cores directory. On
Solaris, use the coreadm command to specify
where to write the core file and how to name it.
For some systems, to get a core file you must also specify the
--core-file-size option to
mysqld_safe. See
Section 6.3.2, “mysqld_safe — MySQL Server Startup Script”. On some systems, such as
Solaris, you do not get a core file if you are also using the
--user option. There might be
additional restrictions or limitations. For example, it might
be necessary to execute ulimit -c unlimited
before starting the server. Consult your system documentation.
The
innodb_buffer_pool_in_core_file
variable can be used to reduce the size of core files on
operating systems that support it. For more information, see
Section 17.8.3.7, “Excluding or Including Buffer Pool Pages from Core Files”.
- --daemonize,
-D
| Command-Line Format | --daemonize[={OFF|ON}] |
| Type | Boolean |
| Default Value | OFF |
This option causes the server to run as a traditional, forking daemon, permitting it to work with operating systems that use systemd for process control. For more information, see Section 2.5.9, “Managing MySQL Server with systemd”.
--daemonize is mutually
exclusive with --initialize and
--initialize-insecure.
If the server is started using the
--daemonize option and is not connected to a
tty device, a default error logging option of
--log-error=“” is used in the absence of an
explicit logging option, to direct error output to the default
log file.
-D is a synonym for
--daemonize.
- --datadir=dir_name,
-h dir_name
| Command-Line Format | --datadir=dir_name |
| System Variable | datadir |
| Scope | Global |
| Dynamic | No |
SET_VAR Hint Applies |
No |
| Type | Directory name |
The path to the MySQL server data directory. This option sets
the datadir system variable.
See the description of that variable.
- --debug[=debug_options],
-# [debug_options]
| Command-Line Format | --debug[=debug_options] |
| System Variable | debug |
| Scope | Global, Session |
| Dynamic | Yes |
SET_VAR Hint Applies |
No |
| Type | String |
| Default Value (Unix) | d:t:i:o,/tmp/mysqld.trace |
| Default Value (Windows) | d:t:i:O,\mysqld.trace |
If MySQL is configured with the
-DWITH_DEBUG=1
CMake option, you can use this option to
get a trace file of what mysqld is doing. A
typical debug_options string is
d:t:o,file_name.
The default is d:t:i:o,/tmp/mysqld.trace on
Unix and d:t:i:O,\mysqld.trace on Windows.
Using -DWITH_DEBUG=1 to
configure MySQL with debugging support enables you to use the
--debug=“d,parser_debug” option
when you start the server. This causes the Bison parser that
is used to process SQL statements to dump a parser trace to
the server's standard error output. Typically, this output is
written to the error log.
This option may be given multiple times. Values that begin
with + or - are added to
or subtracted from the previous value. For example,
--debug=T
--debug=+P sets the value to
P:T.
For more information, see Section 7.9.4, “The DBUG Package”.
- --debug-sync-timeout[=N]
| Command-Line Format | --debug-sync-timeout[=#] |
| Type | Integer |
Controls whether the Debug Sync facility for testing and
debugging is enabled. Use of Debug Sync requires that MySQL be
configured with the
-DWITH_DEBUG=ON
CMake option (see
Section 2.8.7, “MySQL Source-Configuration Options”); otherwise,
this option is not available. The option value is a timeout in
seconds. The default value is 0, which disables Debug Sync. To
enable it, specify a value greater than 0; this value also
becomes the default timeout for individual synchronization
points. If the option is given without a value, the timeout is
set to 300 seconds.
For a description of the Debug Sync facility and how to use
synchronization points, see
MySQL
Internals: Test Synchronization.
- --default-time-zone=timezone
| Command-Line Format | --default-time-zone=name |
| Type | String |
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.
The system_time_zone variable
differs from time_zone.
Although they might have the same value, the latter variable
is used to initialize the time zone for each client that
connects. See Section 7.1.15, “MySQL Server Time Zone Support”.
- --defaults-extra-file=file_name
Read this option file after the global option file but (on
Unix) before the user option file. If the file does not exist
or is otherwise inaccessible, an error occurs. If
file_name is not an absolute path
name, it is interpreted relative to the current directory.
This must be the first option on the command line if it is
used.
For additional information about this and other option-file
options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
- --defaults-file=file_name
Read only the given option file. If the file does not exist or
is otherwise inaccessible, an error occurs. If
file_name is not an absolute path
name, it is interpreted relative to the current directory.
Exception: Even with
--defaults-file,
mysqld reads
mysqld-auto.cnf.
Note
This must be the first option on the command line if it is
used, except that if the server is started with the
--defaults-file and
--install (or
--install-manual) options,
--install (or
--install-manual) must be
first.
For additional information about this and other option-file
options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
- --defaults-group-suffix=str
Read not only the usual option groups, but also groups with
the usual names and a suffix of
str. For example,
mysqld normally reads the
[mysqld] group. If this option is given as
--defaults-group-suffix=_other,
mysqld also reads the
[mysqld_other] group.
For additional information about this and other option-file
options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
- --early-plugin-load=plugin_list
| Command-Line Format | --early-plugin-load=plugin_list |
| Type | String |
| Default Value | empty string |
This option tells the server which plugins to load before
loading mandatory built-in plugins and before storage engine
initialization. Early loading is supported only for plugins
compiled with PLUGIN_OPT_ALLOW_EARLY. If
multiple --early-plugin-load
options are given, only the last one applies.
The option value is a semicolon-separated list of
plugin_library and
name=plugin_library
values. Each plugin_library is the
name of a library file that contains plugin code, and each
name is the name of a plugin to
load. If a plugin library is named without any preceding
plugin name, the server loads all plugins in the library. With
a preceding plugin name, the server loads only the named
plugin from the library. The server looks for plugin library
files in the directory named by the
plugin_dir system variable.
For example, if plugins named myplug1 and
myplug2 are contained in the plugin library
files myplug1.so and
myplug2.so, use this option to perform an
early plugin load:
mysqld --early-plugin-load="myplug1=myplug1.so;myplug2=myplug2.so"
Quotes surround the argument value because otherwise some
command interpreters interpret semicolon
(;) as a special character. (For example,
Unix shells treat it as a command terminator.)
Each named plugin is loaded early for a single invocation of
mysqld only. After a restart, the plugin is
not loaded early unless
--early-plugin-load is used
again.
If the server is started using
--initialize or
--initialize-insecure, plugins
specified by
--early-plugin-load are not
loaded.
If the server is run with
--help, plugins specified by
--early-plugin-load are loaded
but not initialized. This behavior ensures that plugin options
are displayed in the help message.
InnoDB tablespace encryption relies on the
MySQL Keyring for encryption key management, and the keyring
plugin to be used must be loaded prior to storage engine
initialization to facilitate InnoDB
recovery for encrypted tables. For example, administrators who
want the keyring_okv plugin loaded at
startup should use
--early-plugin-load with the
appropriate option value (such as
keyring_okv.so on Unix and Unix-like
systems or keyring_okv.dll on Windows).
For information about InnoDB tablespace
encryption, see Section 17.13, “InnoDB Data-at-Rest Encryption”. For
general information about plugin loading, see
Section 7.6.1, “Installing and Uninstalling Plugins”.
Note
For MySQL Keyring, this option is used only when the
keystore is managed with a keyring plugin. If keystore
management uses a keyring component rather than a plugin,
specify component loading using a manifest file; see
Section 8.4.4.2, “Keyring Component Installation”.
- --exit-info[=flags],
-T [flags]
| Command-Line Format | --exit-info[=flags] |
| Type | Integer |
This is a bitmask of different flags that you can use for
debugging the mysqld server. Do not use
this option unless you know exactly what
it does!
- --external-locking
| Command-Line Format | --external-locking[={OFF|ON}] |
| Type | Boolean |
| Default Value | OFF |
Enable external locking (system locking), which is disabled by
default. 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.
To disable external locking explicitly, use
--skip-external-locking.
External locking affects only
MyISAM table access. For more
information, including conditions under which it can and
cannot be used, see Section 10.11.5, “External Locking”.
- --flush
| Command-Line Format | --flush[={OFF|ON}] |
| System Variable | flush |
| Scope | Global |
| Dynamic | Yes |
SET_VAR Hint Applies |
No |
| Type | Boolean |
| Default Value | OFF |
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 B.3.3.3, “What to Do If MySQL Keeps Crashing”.
Note
If --flush is specified, the
value of flush_time does
not matter and changes to
flush_time have no effect
on flush behavior.
- --gdb
| Command-Line Format | --gdb[={OFF|ON}] |
| Type | Boolean |
| Default Value | OFF |
Install an interrupt handler for SIGINT
(needed to stop mysqld with
^C to set breakpoints) and disable stack
tracing and core file handling. See
Section 7.9.1.4, “Debugging mysqld under gdb”.
On Windows, this option also suppresses the forking that is
used to implement the RESTART
statement: Forking enables one process to act as a monitor to
the other, which acts as the server. However, forking makes
determining the server process to attach to for debugging more
difficult, so starting the server with
--gdb suppresses forking. For a
server started with this option,
RESTART simply exits and does
not restart.
In non-debug settings,
--no-monitor may be used to
suppress forking the monitor process.
- --initialize,
-I
| Command-Line Format | --initialize[={OFF|ON}] |
| Type | Boolean |
| Default Value | OFF |
This option is used to initialize a MySQL installation by
creating the data directory and populating the tables in the
mysql system schema. For more information,
see Section 2.9.1, “Initializing the Data Directory”.
This option limits the effects of, or is not compatible with, a number of other startup options for the MySQL server. Some of the most common issues of this sort are noted here:
- We strongly recommend, when initializing the data
directory with
--initialize, that you specify no additional options other than--datadir, other options used for setting directory locations such as--basedir, and possibly--user, if required. Options for the running MySQL server can be specified when starting it once initialization has been completed and mysqld has shut down. This also applies when using--initialize-insecureinstead of--initialize. - When the server is started with
--initialize, some functionality is unavailable that limits the statements permitted in any file named by theinit_filesystem variable. For more information, see the description of that variable. In addition, thedisabled_storage_enginessystem variable has no effect. - The
--ndbclusteroption is ignored when used together with--initialize. --initializeis mutually exclusive with--bootstrapand--daemonize.
The items in the preceding list also apply when initializing
the server using the
--initialize-insecure option.
- --initialize-insecure
| Command-Line Format | --initialize-insecure[={OFF|ON}] |
| Type | Boolean |
| Default Value | OFF |
This option is used to initialize a MySQL installation by
creating the data directory and populating the tables in the
mysql system schema. This option implies
--initialize, and the same
restrictions and limitations apply; for more information, see
the description of that option, and
Section 2.9.1, “Initializing the Data Directory”.
Warning
This option creates a MySQL root user
with an empty password, which is insecure. For this reason,
do not use it in production without setting this password
manually. See
Post-Initialization root Password Assignment,
for information about how to do this.
- --innodb-xxx
Set an option for the InnoDB storage
engine. The InnoDB options are listed in
Section 17.14, “InnoDB Startup Options and System Variables”.
- --install
[service_name]
| Command-Line Format | --install [service_name] |
| Platform Specific | Windows |
(Windows only) Install the server as a Windows service that
starts automatically during Windows startup. The default
service name is MySQL if no
service_name value is given. For
more information, see Section 2.3.3.8, “Starting MySQL as a Windows Service”.
Note
If the server is started with the
--defaults-file and
--install options,
--install must be first.
- --install-manual
[service_name]
| Command-Line Format | --install-manual [service_name] |
| Platform Specific | Windows |
(Windows only) Install the server as a Windows service that
must be started manually. It does not start automatically
during Windows startup. The default service name is
MySQL if no
service_name value is given. For
more information, see Section 2.3.3.8, “Starting MySQL as a Windows Service”.
Note
If the server is started with the
--defaults-file and
--install-manual options,
--install-manual must be
first.
- --large-pages
| Command-Line Format | --large-pages[={OFF|ON}] |
| System Variable | large_pages |
| Scope | Global |
| Dynamic | No |
SET_VAR Hint Applies |
No |
| Platform Specific | Linux |
| Type | Boolean |
| Default Value | OFF |
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 operating system. Applications that perform a lot of memory accesses may obtain performance improvements by using large pages due to reduced Translation Lookaside Buffer (TLB) misses.
MySQL supports the Linux implementation of large page support
(which is called HugeTLB in Linux). See
Section 10.12.3.3, “Enabling Large Page Support”. For Solaris support of
large pages, see the description of the
--super-large-pages option.
--large-pages is disabled by
default.
- --lc-messages=locale_name
| Command-Line Format | --lc-messages=name |
| System Variable | lc_messages |
| Scope | Global, Session |
| Dynamic | Yes |
SET_VAR Hint Applies |
No |
| Type | String |
| Default Value | en_US |
The locale to use for error messages. The default is
en_US. The server converts the argument to
a language name and combines it with the value of
--lc-messages-dir to produce
the location for the error message file. See
Section 12.12, “Setting the Error Message Language”.
- --lc-messages-dir=dir_name
| Command-Line Format | --lc-messages-dir=dir_name |
| System Variable | lc_messages_dir |
| Scope | Global |
| Dynamic | No |
SET_VAR Hint Applies |
No |
| Type | Directory name |
The directory where error messages are located. The server
uses the value together with the value of
--lc-messages to produce the
location for the error message file. See
Section 12.12, “Setting the Error Message Language”.
- --local-service
| Command-Line Format | --local-service |
(Windows only) A --local-service option
following the service name causes the server to run using the
LocalService Windows account that has
limited system privileges. If both
--defaults-file and
--local-service are given following the
service name, they can be in any order. See
Section 2.3.3.8, “Starting MySQL as a Windows Service”.
- --log-error[=file_name]
| Command-Line Format | --log-error[=file_name] |
| System Variable | log_error |
| Scope | Global |
| Dynamic | No |
SET_VAR Hint Applies |
No |
| Type | File name |
Set the default error log destination to the named file. This affects log sinks that base their own output destination on the default destination. See Section 7.4.2, “The Error Log”.
If the option names no file, the default error log destination
on Unix and Unix-like systems is a file named
host_name.err
in the data directory. The default destination on Windows is
the same, unless the --pid-file
option
(本文超出站点单文档体积上限,已截断)
