现在的位置: 首页 > 综合 > 正文

Mysql:命令选项、配置选项、(全局、会话)系统变量、状态变量:命令选项

2013年03月03日 ⁄ 综合 ⁄ 共 15122字 ⁄ 字号 评论关闭

 

Server Command Options

When you start the mysqld server, you can specify program options
using any of the methods described in Section 4.2.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.2.3.2, “Using Option Files”.

MySQL Enterprise.  For expert advice on setting command
options, subscribe to the MySQL Enterprise Monitor. For more information, see http://www.mysql.com/products/enterprise/advisors.html.

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 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:

You can also set the values of server system variables by using variable
names as options, as described at the end of this section.

  • --help, -?

    Command Line Format -?
    Config File 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
    Config File Format allow-suspicious-udfs
    Value Set
    Type boolean
    Default FALSE

    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. See Section 22.3.2.6, “User-Defined Function
    Security Precautions”
    .

  • --ansi

    Command Line Format --ansi
    Config File 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.3, “Running MySQL in ANSI Mode”,
    and Section 5.1.7, “Server SQL Modes”.

  • --basedir=path,
    -b path

    Command Line Format --basedir=name
    Config File Format basedir
    Option Sets Variable Yes, basedir
    Variable Name basedir
    Variable Scope Global
    Dynamic Variable No
    Value Set
    Type filename

    The path to the MySQL installation directory. All paths are usually resolved
    relative to this directory.

  • --big-tables

    Command Line Format --big-tables
    Config File Format big-tables
    Option Sets Variable Yes, big_tables
    Variable Name big-tables
    Variable Scope Session
    Dynamic Variable Yes
    Value Set
    Type boolean

    Allow large result sets by saving all temporary sets in files. This option
    prevents most “table full” errors, but also slows down
    queries for which in-memory tables would suffice. Since MySQL 3.23.2, the server
    is able to handle large result sets automatically by using memory for small
    temporary tables and switching to disk tables where necessary.

  • --bind-address=IP

    Command Line Format --bind-address=name
    Config File Format bind-address
    Value Set
    Type string
    Default 0.0.0.0
    Range 0.0.0.0-255.255.255.255

    The IP address to bind to. Only one address can be selected. If this option
    is specified multiple times, the last address given is used.

    If no address or 0.0.0.0 is specified, the server
    listens on all interfaces.

  • --binlog-format={ROW|STATEMENT|MIXED}

    Version Introduced 5.1.5
    Command Line Format --binlog-format
    Config File Format binlog-format
    Option Sets Variable Yes, binlog_format
    Variable Name binlog_format
    Variable Scope Both
    Dynamic Variable Yes
    Value Set (>= 5.1.5, <=
    5.1.7)
    Type enumeration
    Default STATEMENT
    Valid Values ROW, STATEMENT
    Value Set (>= 5.1.8, <=
    5.1.11)
    Type enumeration
    Default STATEMENT
    Valid Values ROW, STATEMENT, MIXED
    Value Set (>= 5.1.12, <=
    5.1.28)
    Type enumeration
    Default MIXED
    Valid Values ROW, STATEMENT, MIXED
    Value Set (>= 5.1.29)
    Type enumeration
    Default STATEMENT
    Valid Values ROW, STATEMENT, MIXED

    Specify whether to use row-based, statement-based, or mixed replication
    (statement-based was the default prior to MySQL 5.1.12; in 5.1.12, the default
    was changed to mixed replication; in 5.1.29, the default was changed back to
    statement-based). See Section 16.1.2, “Replication Formats”.
    This option was added in MySQL 5.1.5.

    Important

    MySQL Cluster.  The default value for this option in all MySQL Cluster
    NDB 6.1, 6.2, 6.3, and later 6.x releases is MIXED.
    See Section 17.9.2, “MySQL
    Cluster Replication — Assumptions and General Requirements”
    , for more
    information.

  • --bootstrap

    Command Line Format --bootstrap
    Config File Format bootstrap

    This option is used by the mysql_install_db script to create the MySQL
    privilege tables without having to start a full MySQL server.

    This option is unavailable if MySQL was configured with the --disable-grant-options option. See Section 2.10.2, “Typical configure Options”.

  • --character-sets-dir=path

    Command Line Format --character-sets-dir=name
    Config File Format character-sets-dir
    Option Sets Variable Yes, character_sets_dir
    Variable Name character-sets-dir
    Variable Scope Global
    Dynamic Variable No
    Value Set
    Type filename

    The directory where character sets are installed. See Section 9.2, “The Character Set Used for Data and
    Sorting”
    .

  • --character-set-client-handshake

    Command Line Format --character-set-client-handshake
    Config File Format character-set-client-handshake
    Value Set
    Type boolean
    Default TRUE

    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

    Version Introduced 5.1.6
    Command Line Format --character-set-filesystem=name
    Config File Format character-set-filesystem
    Option Sets Variable Yes, character_set_filesystem
    Variable Name character_set_filesystem
    Variable Scope Both
    Dynamic Variable Yes
    Value Set
    Type string

    The file system character set. This option sets the character_set_filesystem system variable. It was added
    in MySQL 5.1.6.

  • --character-set-server=charset_name, -C charset_name

    Command Line Format --character-set-server
    Config File Format character-set-server
    Option Sets Variable Yes, character_set_server
    Variable Name character_set_server
    Variable Scope Both
    Dynamic Variable Yes
    Value Set
    Type string

    Use charset_name as the default
    server character set. See Section 9.2, “The Character Set Used for Data and
    Sorting”
    . If you use this option to specify a non-default character set, you
    should also use --collation-server to specify the collation.

  • --chroot=path, -r path

    Command Line Format --chroot=name
    Config File Format chroot
    Value Set
    Type filename

    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

    Command Line Format --collation-server
    Config File Format collation-server
    Option Sets Variable Yes, collation_server
    Variable Name collation_server
    Variable Scope Both
    Dynamic Variable Yes
    Value Set
    Type string

    Use collation_name as the default
    server collation. See Section 9.2, “The Character Set Used for Data and
    Sorting”
    .

  • --console

    Command Line Format --console
    Config File Format console
    Platform Specific windows

    (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.

  • --core-file

    Command Line Format --core-file
    Config File Format core-file
    Value Set
    Type boolean
    Default TRUE

    Write a core file if mysqld dies. 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 Mac OS X, 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 4.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.

  • --datadir=path,
    -h path

    Command Line Format --datadir=name
    Config File Format datadir
    Option Sets Variable Yes, datadir
    Variable Name datadir
    Variable Scope Global
    Dynamic Variable No
    Value Set
    Type filename

    The path to the data directory.

  • --debug[=debug_options], -# [debug_options]

    Command Line Format --debug[=debug_options]
    Config File Format debug
    Variable Name debug
    Variable Scope Both
    Dynamic Variable Yes
    Value Set
    Type string
    Default 'd:t:o,/tmp/mysqld.trace

    If MySQL is configured with --with-debug, 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,mysqld.trace'. See MySQL
    Internals: Porting
    .

    As of MySQL 5.1.12, using --with-debug 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.

  • --default-character-set=charset_name (DEPRECATED)

    Command Line Format --default-character-set=name
    Config File Format default-character-set
    Deprecated 5.0
    Value Set
    Type string

    Use charset_name as the default
    character set. This option is deprecated in favor of --character-set-server. See Section 9.2, “The Character Set Used for Data and
    Sorting”
    .

  • --default-collation=collation_name

    Command Line Format --default-collation=name
    Variable Name default-collation
    Variable Scope  
    Dynamic Variable No
    Deprecated 4.1.3
    Value Set
    Type string

    Use collation_name as the default
    collation. This option is deprecated in favor of --collation-server. See Section 9.2, “The Character Set Used for Data and
    Sorting”
    .

  • --default-storage-engine=type

    Command Line Format --default-storage-engine=name
    Config File Format default-storage-engine

    Set the default storage engine (table type) for tables. See Chapter 13, Storage
    Engines
    .

  • --default-table-type=type

    Command Line Format --default-table-type=name
    Config File Format default-table-type
    Deprecated 5.0, by default-storage-engine
    Value Set
    Type string

    This option is a deprecated synonym for --default-storage-engine.

  • --default-time-zone=timezone

    Command Line Format --default-time-zone=name
    Config File Format default-time-zone
    Value Set
    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.

  • --delay-key-write[={OFF|ON|ALL}]

    Command Line Format --delay-key-write[=name]
    Config File Format delay-key-write
    Option Sets Variable Yes, delay_key_write
    Variable Name delay-key-write
    Variable Scope Global
    Dynamic Variable Yes
    Value Set
    Type enumeration
    Default ON
    Valid Values ON, OFF, 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.3, “Tuning Server
    Parameters”
    , and Section 13.5.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.

  • --des-key-file=file_name

    Command Line Format --des-key-file=name
    Config File Format des-key-file

    Read the default DES keys from this file. These keys are used by the DES_ENCRYPT() and DES_DECRYPT() functions.

  • --enable-named-pipe

    Command Line Format --named_pipe
    Config File Format enable-named-pipe
    Platform Specific windows

    Enable support for named pipes. This option applies only on Windows NT, 2000,
    XP, and 2003 systems. For MySQL 5.1.20 and earlier, this option is available
    only when using the mysqld-nt and mysqld-debug servers that support named-pipe connections.
    For MySQL 5.1.21 and later, mysqld-nt is not available, but support is
    included in the standard mysqld and mysqld-debug servers.

  • --enable-pstack

    Command Line Format --enable-pstack
    Config File Format enable-pstack
    Value Set
    Type boolean
    Default FALSE

    Print a symbolic stack trace on failure.

  • --engine-condition-pushdown={ON|OFF}

    Command Line Format --engine-condition-pushdown
    Config File Format engine-condition-pushdown
    Option Sets Variable Yes, engine_condition_pushdown
    Variable Name engine_condition_pushdown
    Variable Scope Both
    Dynamic Variable Yes
    Value Set (>= 5.1.0)
    Type boolean
    Default ON

    Sets the engine_condition_pushdown system variable. For more
    information, see Section 7.2.7, “Condition
    Pushdown Optimization”
    .

  • --event-scheduler[=value]

    Version Introduced 5.1.6
    Command Line Format --event-scheduler[=value]
    Config File Format event-scheduler
    Option Sets Variable Yes, event_scheduler
    Variable Name event_scheduler
    Variable Scope Global
    Dynamic Variable Yes
    Value Set
    Type enumeration
    Default OFF
    Valid Values ON, OFF, DISABLED

    Enable or disable, and start or stop, the event scheduler. This option was
    added in MySQL 5.1.6. Note that its permitted values and behaviour changed in
    MySQL 5.1.11, and again in MySQL 5.1.12.

    For detailed information, see The event-scheduler Option.

  • --exit-info[=flags], -T
    [flags]

    Command Line Format --exit-info[=flags]
    Config File Format exit-info
    Value Set
    Type numeric

    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!

  • --external-locking

    Command Line Format --external-locking
    Config File Format external-locking
    Option Sets Variable Yes, skip_external_locking
    Disabled by skip-external-locking
    Value Set
    Type boolean
    Default FALSE

    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.

    For more information about external locking, including conditions under which
    it can and cannot be used, see Section 7.3.4, “External Locking”.

  • --flush

    Command Line Format --flush
    Config File Format flush
    Variable Name flush
    Variable Scope Global
    Dynamic Variable Yes
    Value Set
    Type boolean
    Default 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.1.4.2, “What to Do If MySQL Keeps
    Crashing”
    .

  • --gdb

    Command Line Format --gdb
    Config File Format gdb
    Value Set
    Type boolean
    Default FALSE

    Install an interrupt handler for SIGINT (needed to
    stop mysqld with ^C to
    set breakpoints) and disable stack tracing and core file handling. See MySQL
    Internals: Porting
    .

  • --general-log[={0|1}]

    Version Introduced 5.1.12
    Command Line Format --general-log
    Config File Format general-log
    Option Sets Variable Yes, general_log
    Variable Name general_log
    Variable Scope Global
    Dynamic Variable Yes
    Value Set
    Type boolean
    Default OFF

    Specify the initial general query log state. With no argument or an argument
    of 1, the --general-log option enables the log. If omitted or
    given with an argument of 0, the option disables the log. This option was added
    in MySQL 5.1.12.

  • --init-file=file_name

    Command Line Format --init-file=name
    Config File Format init-file
    Option Sets Variable Yes, init_file
    Variable Name init_file
    Variable Scope Global
    Dynamic Variable No
    Value Set
    Type filename

    Read SQL statements from this file at startup. Each statement must be on a
    single line and should not include comments.

    This option is unavailable if MySQL was configured with the --disable-grant-options option. See Section 2.10.2, “Typical configure Options”.

  • --innodb-xxx

    The InnoDB options are listed in

抱歉!评论已关闭.