[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mysqld
Command-line Options
When you start the mysqld
server, you specify program options
using any of the methods described in 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 the server uses
the same options each time it runs. The best way to ensure this is to
specify server options 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 [xxxxx_SERVER]
groups, where xxxxx
is the name of the application into which the
server is embedded.
mysqld
accepts many command-line options.
For a list, execute mysqld --help
. Before MySQL 4.1.1, --help
prints the full help message. As of 4.1.1, it prints a brief message; to see
the full list, use mysqld --help --verbose
.
The following list shows some of the most common server options. Options used for replication are listed in a separate section, see 6.7 Replication Startup Options.
--ansi
--sql-mode
option instead.
--basedir=path, -b path
--big-tables
--bind-address=IP
--console
--log-error
is specified. On Windows, mysqld
will not close the console screen if
this option is used.
--character-sets-dir=path
--chroot=path
mysqld
server in a closed environment during startup by using the
chroot()
system call. This is a recommended security measure as of
MySQL 4.0. (MySQL 3.23 is not able to provide a chroot()
jail that is
100% closed.) Note that use of this option somewhat limits LOAD
DATA INFILE
and SELECT ... INTO OUTFILE
.
--core-file
mysqld
dies. For some systems, you must also
specify the --core-file-size
option to mysqld_safe
.
See section mysqld_safe
.
Note that on some systems, such as Solaris, you will
not get a core file if you are also using the --user
option.
--datadir=path, -h path
--debug[=...]
--with-debug
, you can use this
option to get a trace file of what mysqld
is doing.
See section D.1.2 Creating Trace Files.
--default-character-set=charset
--default-table-type=type
--delay-key-write[= OFF | ON | ALL]
DELAYED KEYS
option should be used.
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 DELAYED KEYS
option.
ALL
delays key writes for all MyISAM
tables.
Available as of MySQL 4.0.3.
See section 7.5.2 Tuning Server Parameters.
--delay-key-write-for-all-tables
--delay-key-write=ALL
for use prior to MySQL 4.0.3.
As of 4.0.3, use --delay-key-write
instead.
--des-key-file=filename
DES_ENCRYPT()
and DES_DECRYPT()
from this file.
--enable-external-locking
lockd
does not fully work (as on Linux), you will easily get
mysqld
to deadlock.
This option used to be named --enable-locking
.
--enable-named-pipe
mysqld-nt
and mysqld-max-nt
servers that support
named pipe connections.
--exit-info, -T
mysqld
server. Do not use this option unless you know
exactly what it does!
--flush
--help, -?
--help
displays the full help message.
As of 4.1.1, it displays an abbreviated message only. Use both the
--verbose
and --help
options to see the full message.
--init-file=file
--language=lang_name, -L lang_name
lang_name
may be given as the
language name or as the full pathname to the directory where the language
files are installed.
See section 5.7.2 Non-English Error Messages.
--log[=file], -l [file]
hostname.log
as filename.
--log-bin=[file]
hostname-bin
as filename.
--log-bin-index[=file]
hostname-bin.index
as
filename.
--log-error[=file]
hostname.err
as filename.
--log-isam[=file]
ISAM
/MyISAM
changes to this file (used only when
debugging ISAM
/MyISAM
).
--log-long-format
--log-slow-queries
and --log-long-format
, then
queries that are not using indexes also are logged to the slow query log.
Note that --log-long-format
is deprecated as of MySQL version
4.1, when --log-short-format
was introduced (the long log format
is the default setting since version 4.1). Also note that starting with
MySQL 4.1 the --log-queries-not-using-indexes
option is available
for the purpose of logging queries that do not use indexes to the slow
queries log.
--log-queries-not-using-indexes
--log-slow-queries
, then also
queries that are not using indexes are logged to the slow query log. This
option is available as of MySQL 4.1. See section 5.8.5 The Slow Query Log.
--log-short-format
--log-slow-queries[=file]
long_query_time
seconds
to execute to file. Note that the default for the amount of information
logged has changed in MySQL 4.1. See the --log-long-format
and
--log-long-format
options for details. See section 5.8.5 The Slow Query Log.
--log-update[=file]
file.#
where #
is a unique number if not
given. See section 5.8.3 The Update Log. The update log is deprecated and is
removed in MySQL 5.0.0; you should use the binary log instead
(--log-bin
). See section 5.8.4 The Binary Log. Starting from version 5.0.0,
using --log-update
will just turn on the binlog instead
(see section C.1.2 Changes in release 5.0.0 (22 Dec 2003: Alpha)).
--log-warnings, -W
Aborted connection...
to the
`.err' file. Enabling this option is recommended, for example, if you
use replication (you will get more information about what is happening,
such as messages about network failures and reconnections). See section A.2.10 Communication Errors / Aborted Connection.
This option used to be called --warnings
.
--low-priority-updates
INSERT
/DELETE
/UPDATE
)
will have lower priority than selects. It can also be done via
{INSERT | REPLACE | UPDATE | DELETE} 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.
--memlock
mysqld
process in memory. This works on systems such as
Solaris that support the mlockall()
system call. This
may 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.
--myisam-recover [=option[,option...]]]
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, seprate them by commas.
You can also use a value of ""
to disable this
option. If this option is used, mysqld
will on open check if the
table is marked as crashed or if the table wasn't closed properly.
(The last option works only if you are running with
--skip-external-locking
.) If this is the case mysqld
will run
check on the table. If the table was corrupted, mysqld
will
attempt to repair it.
The following options affects how the repair works.
Option | Description |
DEFAULT | The same as not giving any option to |
BACKUP | If the data table was changed during recover, save a | backup of the `table_name.MYD' datafile as `table_name-datetime.BAK'.
FORCE | Run recover even if we will 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 a table is automatically repaired, MySQL will add a note
about this in 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 will force a repair of a table even if some rows
would be deleted, but it will keep the old datafile as a backup so that
you can later examine what happened.
--new
--new
option can be used to make the server
behave as 4.1 in certain respects, easing a 4.0 to 4.1 upgrade:
TIMESTAMP
is returned as a string with the format
'YYYY-MM-DD HH:MM:SS'
.
See section 11. Column Types.
This option can be used to help you see how your applications will behave in MySQL 4.1, without actually upgrading to 4.1.
--pid-file=path
mysqld_safe
.
--port=num, -P num
--old-protocol, -o
--one-thread
--open-files-limit=
mysqld
.
If this is not set or set to 0, then mysqld
will use this value
to reserve file descriptors to use with setrlimit()
. If this
value is 0 then mysqld
will reserve max_connections*5
or
max_connections + table_cache*2
(whichever is larger) number of
files. You should try increasing this if mysqld
gives you the
error 'Too many open files'.
--set-variable=name=value, -O value
--help
to list the
variables. You can find a full description for all variables in the
SHOW VARIABLES
section in this manual. See section SHOW VARIABLES
. The section on tuning server parameters includes
information on how to optimize them. See section 7.5.2 Tuning Server Parameters.
Please note that --set-variable=name=value
and -O name=value
syntax is deprecated as of MySQL 4.0.2. In 4.0.2, you can set variables
directly using --variable-name=value
syntax, and --set-variable
is no longer needed.
If you want to restrict the maximum value a startup option can be set to
with SET
, you can define this by using the
--maximum-variable-name
command line option.
See section SET OPTION
.
Note that when setting a variable to a value, MySQL may automatically correct it to stay within a given range, or adjust the value to the closest allowable value if only certain values are allowed.
--safe-mode
--safe-show-database
SHOW DATABASES
statement returns only those
databases for which the user has some kind of privilege.
From version 4.0.2 this option is deprecated and doesn't do anything
(the option is enabled by default) as we now have the
SHOW DATABASES
privilege. See section GRANT
.
--safe-user-create
GRANT
statement, if the user doesn't have INSERT
privilege to the
mysql.user
table or any column in this table.
--skip-bdb
BDB
storage engine. This saves memory and may speed
up some operations.
Do not use this operation if you require BDB
tables.
--skip-concurrent-insert
MyISAM
tables. (This is only to be used if you think you have found a bug in this
feature.)
--skip-delay-key-write
DELAY_KEY_WRITE
option for all tables.
As of MySQL 4.0.3, you should use --delay-key-write=OFF
instead.
See section 7.5.2 Tuning Server Parameters.
--skip-external-locking
isamchk
or myisamchk
you must
shut down the server. See section 1.2.3 MySQL Stability. Note that in MySQL Version
3.23, you can use CHECK TABLE
and REPAIR TABLE
to check and repairMyISAM
tables.
This option used to be named --skip-locking
.
--skip-grant-tables
mysqladmin
flush-privileges
or mysqladmin reload
command, or by issuing a
FLUSH PRIVILEGES
statement.)
--skip-host-cache
--skip-innodb
InnoDB
storage engine. This saves memory and disk
space and may speed up some operations.
Do not use this operation if you require InnoDB
tables.
--skip-isam
ISAM
storage engine. As of MySQL 4.1, ISAM
is
disabled by default, so this option applies only if the server was configured
with support for ISAM
.
This option was added in MySQL 4.1.1.
--skip-name-resolve
Host
column values in the
grant tables must be IP numbers or localhost
. See section 7.5.5 How MySQL uses DNS.
--skip-networking
mysqld
must be made via named pipes (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.5 How MySQL uses DNS.
--skip-new
--skip-symlink
--skip-symbolic-links
, for use before MySQL
4.0.13.
--symbolic-links, --skip-symbolic-links
directory.sym
file that contains the path to the real directory.
See section 7.6.1.3 Using Symbolic Links for Databases on Windows.
MyISAM
index file or datafile 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 CREATE TABLE
.
This option was added in MySQL 4.0.13.
--skip-safemalloc
--with-debug=full
, all MySQL programs
checks 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.
--skip-show-database
SHOW DATABASES
statement, unless the user has the
SHOW DATABASES
privilege.
--skip-stack-trace
mysqld
under a debugger. On some systems, you also must use
this option to get a core file. See section D.1 Debugging a MySQL server.
--skip-thread-priority
--socket=path
MySQL
.
--sql-mode=value[,value[,value...]]
--temp-pool
--transaction-isolation=level
READ-UNCOMMITTED
,
READ-COMMITTED
,
REPEATABLE-READ
, or
SERIALIZABLE
.
See section SET TRANSACTION
.
--tmpdir=path, -t path
/tmp
directory resides on a partition that
is too small to hold temporary tables. Starting from MySQL 4.1, 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. It is possible to set tmpdir
to point to a memory-based filesystem, except if the MySQL server is a
slave replication server. If it is a slave, some of its temporary files
are needed to survive a machine's reboot. (For example, to replicate
temporary tables or LOAD DATA INFILE
statements). In this case,
a memory-based tmpdir
that is cleared when the machine reboots is
not suitable; a disk-based tmpdir
is necessary.
--user={user_name | user_id}, -u {user_name | user_id}
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 will change its user ID during its startup sequence, causing it
to run as that particular user rather than as root
.
See section 5.3.1 General Security Guidelines.
Starting from MySQL 3.23.56 and 4.0.12:
To avoid a possible security hole where a user adds a --user=root
option to some `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
`datadir/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' will be 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.
--version, -V
You can change the values of most system variables for a running server with the
SET
statement. See section SET OPTION
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |