Team LiB
Previous Section Next Section

mysqld

mysqld is the MySQL server. It provides database access to client programs, so it must be running or clients cannot use databases administered by the server. When mysqld starts, it opens network interfaces on which to listen and then waits for client connections. mysqld is multi-threaded and processes each client connection using a separate thread to provide concurrency among clients. Statements that write to the database are executed atomically; when the server begins executing such a statement, it will execute no other statement for the data involved until the current statement has finished. For example, no two clients can modify the same row in a table at the same time.

Usage

The usual invocation sequence is simply the server name followed by any desired options:

mysqld [options]

On Windows NT-based systems, a server can be installed to run as a service. For example, the mysqld-nt server might be installed to run automatically at system startup time, or removed as a service as follows:

C:\> mysqld-nt --install
C:\> mysqld-nt --remove

The default service name is MySQL. You can provide a service name following the option:

C:\> mysqld-nt --install service_name
C:\> mysqld-nt --remove service_name

This allows multiple servers to be run under different service names. With no service_name argument, MySQL is used as the service name and the server reads the [mysqld] group from option files at startup time. With a service_name argument, that name becomes the service name and the server reads the [service_name] group from option files at startup time.

You can also provide a --defaults-file option following the service name to specify an additional file of options for the server to read at startup time:

C:\> mysqld-nt --install service_name --defaults-file=file_name

In this case, the service_name argument is not optional.

The preceding remarks about --install apply to --install-manual as well.

Standard Options Supported by mysqld

--character-sets-dir      --port                    --user
--debug                   --shared-memory-base-name --verbose
--help                    --socket

Before MySQL 4.1.1, the --help option by itself displays the full help message that shows the complete list of options and the default system variable values. This list has grown quite large, so as of MySQL 4.1.1, --help by itself displays only a brief usage message. To see the full help message, use this command:

% mysqld --verbose --help

mysqld also supports the standard SSL options.

Note that although --socket is supported, the corresponding short form (-S) is not. On Windows, --socket sets the pipe name if the server supports named-pipe connections.

On Unix, if the --user option is given, it specifies the username or numeric user ID of the account to use for running the server. In this case, when the server starts, it looks up the user and group ID values of the account from the password file and then changes its user and group IDs to match. In this way, the server runs with the privileges associated with that user, not root privileges. (The server must be started as root for the --user option to be effective; it will not be able to change its user ID otherwise.)

Options Specific to mysqld

The first section of options listed here are general options. It is followed by sections that list options specific to Windows, to particular storage engines, and to replication.

  • --ansi, -a

    Tell the server to use standard SQL behavior for certain types of syntax, rather than MySQL-specific syntax. This option can be used to make the server more standards-compliant.

    This option is equivalent to using the --sql-mode option with the REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, and ONLY_FULL_GROUP_BY flags.

  • --basedir=dir_name, -b dir_name

    The pathname to the MySQL installation directory. Many other pathnames are resolved in relation to this directory if they are given as relative pathnames.

  • --big-tables

    Allow large result sets to be processed by saving all temporary results to disk rather than by holding them in memory. This avoids most "table full" messages that occur as a result of having insufficient memory to hold large result sets. This option is unnecessary as of MySQL 3.23 because the server automatically saves results to disk as required.

  • --bind-address=ip_addr

    Bind to the given IP address. Normally, mysqld binds to the default IP address for the host on which the server is running. This option can be used to select an alternative address to bind to if the host has multiple addresses.

  • --bootstrap

    This option is used by installation scripts when you first install MySQL.

  • --character-set-server=charset

    The default server character set. This option was introduced in MySQL 4.1.3.

  • --chroot=dir_name, -r dir_name

    Run the MySQL server anchored to the given directory as its root directory. See the chroot() Unix manual page for more information on running in a chroot()-ed environment.

  • --collation-server=collation

    The default server collation. This option was introduced in MySQL 4.1.3.

  • --concurrent-insert (boolean)

    Allow concurrent inserts on MyISAM tables. If a MyISAM table has no holes in the middle, concurrent inserts add new records at the end of the table while retrievals are being performed on the existing rows. This option is enabled by default. To disallow concurrent inserts, use --skip-concurrent-insert.

  • --core-file

    Cause a core file to be generated before exiting when a fatal error occurs.

  • --datadir=dir_name, -h dir_name

    The pathname to the MySQL data directory.

  • --default-character-set=charset

    The default character set. This option is deprecated as of MySQL 4.1.3; use --character-set-server instead.

  • --default-collation=collation

    The default collation. This option is deprecated as of MySQL 4.1.3; use --collation-server instead.

  • --default-storage-engine=type

    The default table storage engine to use. The type value should be the name of one of the storage engines that the server supports, such as ISAM, MyISAM, HEAP, BDB, or InnoDB. (The value is not case sensitive.) If this option is not specified, the server uses MyISAM. This option was introduced in MySQL 4.1.2.

  • --default-table-type=type

    This option has the same effect as --default-storage-engine, but can be used in servers older than MySQL 4.1.2 when --default-storage-engine was introduced.

  • --default-time-zone=tz_name

    Set the server's default time zone to tz_name. Time zone values are described in "Configuring Time Zone Support," in Chapter 11. This option sets the time_zone system variable, not the system_time_zone variable. It was introduced in MySQL 4.1.3.

  • --delay-key-write=val

    Set the mode used by the server for handling delayed key writes for MyISAM files. val can be ON (delay key writes on a per-table basis, according to any DELAY_KEY_WRITE value specified when tables were created; this is the default), OFF (never delay key writes for any MyISAM table), or ALL (delay key writes for all MyISAM tables). OFF and ALL enforce a policy that is applied regardless of how individual tables were defined when they were created.

    It's common to run replication slave servers with --delay-key-write=ALL to obtain increased performance for MyISAM tables by delaying key writes no matter how the tables were created originally.

  • --des-key-file=file_name

    The name of the file that holds DES keys for the DES_ENCRYPT() and DES_DECRYPT() functions. For a description of the format of this file, see the entry for DES_ENCRYPT() in Appendix C, "Operator and Function Reference."

  • --enable-locking

    This option is deprecated. See the description for --external-locking.

  • --enable-pstack (boolean)

    Enable symbolic stack printing when an error occurs.

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

    Cause the server to produce debugging information when it terminates. If n is specified after -T, there must be no intervening space or the value will not be interpreted correctly.

  • --external-locking (boolean)

    Enable external locking (filesystem locking) for systems such as Linux, where external locking is off by default.

    External locking is effective only for operations that just read tables, such as table checking. For operations that modify tables, such as repairs, you should stop the server while running myisamchk to avoid the risk of table damage. (See "Performing Database Maintenance with the Server Running," in Chapter 13 for details.) In general, it is preferable to use mysqlcheck rather than myisamchk if possible. mysqlcheck tells the server to do the work, so there is no need to coordinate with the server explicitly or to know anything about external locking.

  • --flush

    Flush all tables to disk after each update. This reduces the risk of table corruption in the event of a crash but seriously degrades performance. Thus, it is useful only if you have an unstable system. This option applies only to MyISAM and ISAM tables.

  • --gdb

    Set up signal handlers that are useful for debugging with gdb.

  • --init-connect=str

    Statements to be executed for each client when the client connects. The value should be one or more SQL statements, separated by semicolons. The statements are executed only for clients that do not have the SUPER privilege. This option was introduced in MySQL 4.1.2.

  • --init-file=file_name

    Name of a file of SQL statements to be executed at startup time. A relative filename is interpreted starting at the data directory. The file should contain one statement per line.

  • --isam (boolean)

    Use the ISAM storage engine. If ISAM is compiled in, it is enabled by default. If you don't use ISAM tables, you can use --skip-isam to disable ISAM, which saves memory. This option was introduced in MySQL 4.1.1.

  • --language=lang_name, -L lang_name

    Display error messages to clients in the specified language. Normally, lang_name is a value such as english or german, but it can also be the full pathname to the directory containing the language files.

  • --local-infile (boolean)

    Allow or disallow LOAD DATA LOCAL. Invoke the server with --local-infile or --disable-local-infile to enable or disable LOCAL on the server side.

  • --log[=file_name], -l[file_name]

    Turn on logging to the general log file. The general log contains information about client connections and SQL statements. If file_name is not given, the log filename is HOSTNAME.log in the data directory, where HOSTNAME is the name of the server host. If file_name is given as a relative path, it is interpreted starting at the data directory. If file_name is specified after -l, there must be no intervening space or the value will not be interpreted correctly.

  • --log-bin[=file_name]

    Enable the binary log. If file_name is not given, the log filename is HOSTNAME-bin.nnnnnn in the data directory, where HOSTNAME is the name of the server host and nnnnnn is a sequence number that is incremented by one each time a new log is created. If file_name is given as a relative path, it is interpreted starting at the data directory.

  • --log-bin-index=file_name

    Enable the binary log index file. If file_name is not given, the default name is the same as the basename of the binary logs, with an .index extension. If file_name is given as a relative path, it is interpreted starting at the data directory.

  • --log-error[=file_name]

    The error log filename. If file_name is not given, the log filename is HOSTNAME.err in the data directory, where HOSTNAME is the name of the server host. If file_name is given as a relative path, it is interpreted starting at the data directory. If file_name is given as a name that has no extension, mysqld adds an extension of .err.

  • --log-isam[=file_name]

    Enable index file logging. This is used only for debugging ISAM/MyISAM operations. If you specify no name, the default is myisam.log in the data directory.

  • --log-long-format

    Write additional information to the binary log, update log, and slow-query log if those logs are enabled. This option is deprecated as of MySQL 4.1.1; extra information is now the default for logging, which you can disable with the --log-short-format option.

  • --log-queries-not-using-indexes

    If the slow-query log is enabled, log queries to that log that do not use indexes. This option was introduced in MySQL 4.1.1.

  • --log-short-format

    Write less information to the binary log, update log, and slow-query log if those logs are enabled. This option was introduced in MySQL 4.1.1.

  • --log-slow-queries[=file_name]

    Turn on slow-query logging to the named file. If no file is named, the default name is HOSTNAME-slow.log in the data directory, where HOSTNAME is the name of the server host. If file_name is given as a relative path, it is interpreted starting at the data directory.

  • --log-update[=file_name]

    Turn on logging to the update log file. The update log contains the text of any query that modifies database tables. If file_name is not given, the update log filename is HOSTNAME.nnnnnn in the data directory, where HOSTNAME is the name of the server host and nnnnnn is a sequence number one greater than that of the previous update log.

    If file_name is given and the final component contains no extension, the server adds a numeric extension of the form nnnnnn with a value as previously described. If the final component of the pathname includes an extension, that name is used without modification as the update log filename. If file_name is given as a relative path, it is interpreted starting at the data directory.

    The update log has been deprecated in favor of the binary log since the binary log was instituted during the MySQL 3.23 series. As of MySQL 5.0, the update log is removed completely, so --log-update enables the binary log if you haven't also given the --log-bin option.

  • --log-warnings[=n],

    Write certain non-critical warning messages to the error log. Before MySQL 4.1.2, --log-warnings is a boolean option. As of MySQL 4.1.2, you can give the option without a value to enable warnings, or with a value 0 or 1 to disable or enable warnings. This option is on by default in MySQL 4.1.2 and up, and off before that. As of MySQL 4.1.4, you can give the option without a value twice or specify it with a value of 2 to enable logging of aborted connections.

  • --low-priority-updates (boolean)

    Give updates lower priority than retrievals.

  • --memlock (boolean)

    Lock the server in memory if possible. This option is effective only on Solaris, and only if the server is run as root.

  • --myisam-recover[=level]

    Enable automatic table repair for MyISAM tables. A repair is done if, when the server opens a MyISAM table, the table is marked as crashed or was not closed properly when last used. level can be empty or a comma-separated list of one or more of the following values: DEFAULT (same as specifying no level), BACKUP (create a backup of the table if the repair will change it), FORCE (force recovery even if more than a row of data will be lost), or QUICK (quick recovery).

    It's a good idea to use this option if you run the server with the --delay-key-write option or have MyISAM tables configured to allow delayed index writes.

  • --ndbcluster (boolean)

    Use the NDBCLUSTER storage engine. If NDBCLUSTER is compiled in, it is enabled by default. If you don't use NDBCLUSTER tables, you can use --skip-ndbcluster to disable NDBCLUSTER, which saves memory. This option was introduced in MySQL 4.1.2.

  • --new, -n

    This option causes a MySQL 4.0 server to use some 4.1 behaviors. There is a corresponding new system variable that has the same effect. The following behaviors are affected when the option is enabled:

    • In MySQL 4.0.12 and up, hexadecimal strings are treated as strings by default instead of as numbers:

      mysql> SELECT 0xee00 < 0xff;
      +---------------+
      | 0xee00 < 0xff |
      +---------------+
      |             0 |
      +---------------+
      mysql> SET new = 1;
      mysql> SELECT 0xee00 < 0xff;
      +---------------+
      | 0xee00 < 0xff |
      +---------------+
      |             1 |
      +---------------+
      

    • In MySQL 4.0.13 and up, the server uses the 4.1 format for display of TIMESTAMP values (that is, it uses the same format as for DATETIME values).

  • --old-passwords

    As of MySQL 4.1, the server supports a more secure password encryption method than previously. Existing accounts that have passwords encrypted the old way are still supported, but new passwords are encrypted using the new method. The --old-passwords option forces the old method to be used even when assigning new passwords. (This can be useful if you want to be able to downgrade the server or move the accounts to an older server.) This option was introduced in MySQL 4.1.0.

  • --one-thread

    Run using a single thread. This is used for debugging under Linux, which normally uses three threads at a minimum.

  • --pid-file=file_name

    When mysqld starts, it writes its process ID (PID) into a file. This option specifies the pathname of the PID file. The file may be used by other processes to determine the server's process number, typically for purposes of sending a signal to it. For example, mysql.server reads the file when it sends a signal to the server to shut down. If file_name is given as a relative path, it is interpreted starting at the data directory. This option has no effect for the embedded server, or on Windows prior to MySQL 4.1.6.

  • --safe-mode

    This option is like --skip-new, but disables even more things. You can try it if MySQL appears to be unstable or if complex statements seem to yield incorrect results.

  • --safe-show-database (boolean)

    Formerly, this option was used for control over the SHOW DATABASES statement. It does nothing now. MySQL administrators should use the SHOW DATABASES privilege to manage access to database names.

  • --safe-user-create (boolean)

    Disallow account creation by users who do not have INSERT access to the user grant table.

  • --safemalloc-mem-limit=n

    Simulate a memory shortage. The value represents the limit on the amount of memory available for allocation. This option can be used only if the server was built with the --with-debug=full option at configuration time.

  • --secure-auth (boolean)

    Prevent clients from connecting unless they use the more secure password format introduced in MySQL 4.1. This option was introduced in MySQL 4.1.1.

  • --skip-grant-tables (boolean)

    Disable use of the grant tables for verifying client connections. This gives any client full access to do anything. It also disables the GRANT, REVOKE, SET PASSWORD, CREATE USER, DROP USER, and RENAME USER statements. You can tell the server to begin using the grant tables again by issuing a FLUSH PRIVILEGES statement or a mysqladmin flush-privileges command, or by restarting it without --skip-grant-tables.

  • --skip-host-cache

    Disable use of the hostname cache.

  • --skip-locking

    This option is deprecated. See the description for --external-locking.

  • --skip-name-resolve

    Do not try to resolve hostnames. If this option is specified, the grant tables must specify hosts by IP number or as localhost.

  • --skip-networking

    This option disables TCP/IP connections. Only local clients can connect, and must do so using a non-TCP/IP interface. Unix clients can connect using a Unix socket file. Windows clients can connect using shared memory or a named pipe.

  • --skip-new

    Do not use new, possibly unsafe routines.

  • --skip-safemalloc

    Do not perform memory allocation checking. This option can be used only if the server was built with the --with-debug=full option at configuration time.

  • --skip-show-database

    By default, the SHOW DATABASES statement can be issued by any user. In which case, it displays all databases if the user has the SHOW DATABASES privilege, or those databases for which the user has some privilege otherwise. With the --skip-show-database option, the SHOW DATABASES statement can be used only by users who have the SHOW DATABASES privilege, and it displays all databases.

  • --skip-stack-trace

    Don't print a stack trace when failure occurs.

  • --skip-symlink

    This option is deprecated in favor of --skip-symbolic-links. See the description of --symbolic-links.

  • --skip-thread-priority

    Normally, updates (statements that modify tables) run at a higher priority than statements that retrieve data. If that is undesirable, this option causes the server not to give different priorities to different types of statements.

  • --sql-bin-update-same (boolean)

    Yoke together sql_log_bin and sql_log_update so that setting one (with the SET statement) sets the other as well. This option is obsolete as of MySQL 5.0, when the update log no longer exists. The binary log should be used instead.

  • --sql-mode=flags

    This option modifies certain aspects of the server's behavior to cause it to act according to standard SQL, or to be compatible with other database servers or older MySQL servers. flags should be a comma-separated list of one or more mode values, or an empty string to clear the mode. The allowable mode values are given in the description of the sql_mode system variable in Appendix D, "System, Status, and User Variable Reference."

  • --symbolic-links (boolean)

    For Unix, this option enables symbolic linking for MyISAM table data and index files (using the DATA DIRECTORY and INDEX DIRECTORY table creation options). For Windows, it enables symbolic linking of database directories. These techniques are discussed in Chapter 10, "The MySQL Data Directory." Database symlinking support on Windows is enabled by default; use --skip-symbolic-links to disable it.

  • --sync-frm (boolean)

    Synchronize each .frm file to disk when it is created. This option is enabled by default; use --skip-sync-frm to disable it.

  • --temp-pool (boolean)

    With this option, the server uses a small set of names for temporary files, rather than creating a unique name for each file. This avoids some caching problems on Linux. This option is enabled by default; disable it with --disable-temp-pool.

  • --transaction-isolation=level

    Set the default transaction isolation level. The allowable level values are READ-UNCOMMITTED, READ-COMMITTED, REPEATABLE-READ, and SERIALIZABLE.

  • --tmpdir=dir_name, -t dir_name

    The pathname of the directory to use for temporary files. The option value can be given as a list of directories, to be used in round-robin fashion. Under Unix, separate directory names by colons; under Windows or NetWare, separate them by semicolons.

  • --warnings

    This option is deprecated. See the description for --log-warnings.

Windows Options

The options in this section are available only for servers running under Windows. Several of them are related to Windows services and apply only to NT-based systems.

  • --console (boolean)

    Display a console window for error messages.

  • --enable-named-pipe (boolean)

    MySQL servers with -nt in their name support named-pipe connections on Windows NT-based systems, but named-pipe support is disabled by default. This option can be used to turn on named pipe support. The default pipe name is MySQL (not case sensitive). The name can be changed with the --socket option.

    Note that enabling named pipes may cause problems at server shutdown time. Test your system to make sure that this option works properly for you.

  • --install [service_name]

    Install the server as a service that runs automatically when Windows starts. If service_name is not given, the default service is named MySQL. (Windows NT-based systems only.)

  • --install-manual [service_name]

    Install the server as a service that does not run automatically when Windows starts. You must explicitly start the service yourself. If service_name is not given, the default service is named MySQL. (Windows NT-based systems only.)

  • --remove [service_name]

    Remove the server as a service. If service_name is not given, the default service is named MySQL. (Windows NT-based systems only.)

  • --shared-memory (boolean)

    Enable support for shared-memory connections. The default shared memory name is MYSQL (case sensitive). The name can be changed with the --shared-memory-base-name option.

  • --standalone

    Run the server as a standalone program rather than as a service. (Windows NT-based systems only.)

BDB Options

The options in this section are specific to the BDB storage engine.

  • --bdb (boolean)

    Use the BDB storage engine. If BDB is compiled in, it is enabled by default. If you don't use BDB tables, you can use --skip-bdb to disable BDB, which saves memory.

  • --bdb-home=dir_name

    The BDB home directory. If specified explicitly, the value should be the same as for --datadir.

  • --bdb-lock-detect=val

    Set the BDB deadlock detection/resolution mode. val should be one of the following values, indicating how to choose a transaction to abort when it becomes necessary to break a deadlock: YOUNGEST (most recently started transaction), OLDEST (longest-lived transaction), RANDOM (a randomly chosen transaction), or DEFAULT (transaction chosen using the default policy, which currently is the same as RANDOM).

  • --bdb-logdir=dir_name

    The pathname to the directory where the BDB storage engine writes log files.

  • --bdb-no-recover

    Tell the BDB storage engine not to attempt auto-recovery of BDB files at startup time. This option can be useful for getting the server running in some cases when it exits at startup due to auto-recovery failure.

  • --bdb-no-sync

    Don't flush BDB logs synchronously.

  • --bdb-shared-data

    Start the BDB storage engine in multi-process mode.

  • --bdb-tempdir=dir_name

    The pathname to the directory where the BDB storage engine writes temporary files.

  • --sync-bdb-logs

    Flush the BDB logs synchronously. This option is enabled by default; disable it with --disable-sync-bdb-logs.

InnoDB Options

The options in this section are specific to the InnoDB storage engine.

  • --innodb (boolean)

    Use the InnoDB storage engine. If InnoDB is compiled in, it is enabled by default. If you don't use InnoDB tables, you can use --skip-innodb to disable InnoDB, which saves memory.

  • --innodb_autoextend_increment=size

    If the InnoDB shared tablespace is configured to be auto-extending, this variable controls the increment size for extending it. The value is specified in megabytes. The default value is 8MB. This option was introduced in MySQL 4.1.5.

  • --innodb_checksums (boolean)

    Enable InnoDB table checksum calculation. Checksums are on by default; disable them with --skip-innodb-checksums. This option was introduced in MySQL 5.0.3.

  • --innodb_data_file_path=filespec_list

    The specifications for the InnoDB tablespace component files. The format of the option value is discussed in the InnoDB configuration instructions in Chapter 11.

  • --innodb_data_home_dir=dir_name

    The pathname to the directory under which the InnoDB tablespace components are located.

  • --innodb_doublewrite (boolean)

    Enable the InnoDB doublewrite buffer. The buffer is on by default; disable it with --skip-innodb-doublewrite. This option was introduced in MySQL 5.0.3.

  • --innodb_fast_shutdown (boolean)

    Speed up the server shutdown process; the InnoDB storage engine skips some of the operations that it performs normally.

  • --innodb_file_per_table (boolean)

    Enabling this variable causes InnoDB to create new tables with individual tablespace files. That is, each InnoDB table has an .ibd tablespace file located in its database directory. The shared tablespace is used only for the InnoDB data dictionary entry, not for data or index storage. The option is disabled by default. It was introduced in MySQL 4.1.1.

  • --innodb_flush_log_at_trx_commit=n

    This option has a value of 1 by default, which causes InnoDB log flushing when transactions are committed so that ACID properties are guaranteed. Setting the option to 0 reduces the amount of flushing to disk that InnoDB performs. However, this comes at a somewhat increased potential for losing a few of the most recent committed transactions if a crash occurs. The following table shows the possible values:

    Value

    Meaning

    0

    Write to log once per second and flush to disk

    1

    Write to log at each commit and flush to disk

    2

    Write to log at each commit, but flush to disk only once per second


  • --innodb_flush_method=val

    This option applies only on Unix. It specifies the method to use for flushing data to the InnoDB logs. The allowable values are fdatasync (the default) and O_DSYNC.

  • --innodb_locks_unsafe_for_binlog (boolean)

    This option causes InnoDB to use only row-level locking and not use next-key locking. It is off by default. For further information, see the description for the innodb_locks_unsafe_for_binlog system variable in Appendix D, "System, Status, and User Variable Reference." This option was introduced in MySQL 4.1.4.

  • --innodb_log_arch_dir=dir_name

    This option is not currently used.

  • --innodb_log_group_home_dir=dir_name

    The pathname to the directory where the InnoDB storage engine should write its log files.

  • --innodb_log_archive=n

    This option is not currently used.

  • --innodb_max_dirty_pages_pct=n

    The percentage of dirty pages that InnoDB allows in its buffer pool before it considers it necessary to flush the log to disk. Allowable values are from 0 to 100; the default is 90.

  • --innodb_safe_binlog

    Following crash recovery by InnoDB, truncate the binary log to the last statement or transaction that was not rolled back. This option was introduced in MySQL 4.1.3.

  • --innodb_status_file (boolean)

    Write SHOW INNODB STATUS information to a file named innodb_status.nnnnnn in the data directory periodically. nnnnnn is the server process ID number. These status files are not removed except for clean shutdown. Periodically, you should remove those that no longer are needed. This option was introduced in MySQL 4.1.4.

  • --innodb_table_locks (boolean)

    Cause InnoDB to acquire an internal table lock when LOCK TABLE is used for an InnoDB table. This option was introduced in MySQL 4.1.7.

Replication Options

The options in this section pertain to MySQL's replication capabilities.

For a replication slave server, several options are used in conjunction with the master information file (named master.info in the data directory by default). When the server starts, if no master.info file exists, it uses the values of the --master-host, --master-user, --master-password, --master-port, --master-connect-retry, and --master-ssl-xxx options when establishing the connection to the master server. It also saves the values in the master.info file. If the file exists when the slave starts, it uses the contents of the file and ignores the options. You must remove the file and restart the server for the options to take effect. The name of the file itself can be changed with the --master-info-file option.

The --report-xxx and --show-slave-auth-info options affect the output of SHOW SLAVE HOSTS on the master, as described in Appendix E, "SQL Syntax Reference."

  • --abort-slave-event-count=n

    This option is used by mysql-test-run for replication testing.

  • --binlog-do-db=db_name

    For a replication master, log updates only for the named database. No other databases will be replicated. To log updates for multiple databases, repeat the option once for each database name.

  • --binlog-ignore-db=db_name

    For a replication master, do not log updates for the named database. To ignore updates for multiple databases, repeat the option once for each database name.

  • --disconnect-slave-event-count=n

    This option is used by mysql-test-run for replication testing.

  • --init-rpl-role=val

    Indicate the initial replication role; val can be master or slave. This option is used by the mysql-test-run script for replication testing.

  • --init-slave=str

    For a master replication server, this option specifies statements to be executed for each slave replication server when the slave connects. The value should be one or more SQL statements, separated by semicolons. This option was introduced in MySQL 4.1.2.

  • --log-slave-updates (boolean)

    This option causes a replication slave to log updates that it receives from the master server to its own binary log. It's necessary to do this if the slave acts as a master to another server (that is, if you chain slave servers).

  • --master-connect-retry=n

    For a replication slave, the number of seconds between attempts to connect to the master if the master is unavailable.

  • --master-host=host_name

    For a replication slave, the host where the master server is running. host_name can be given as a name or IP number.

  • --master-info-file=file_name

    For a replication slave, the name of the file that stores information about the current replication state. The contents of this file are the replication coordinates (master binary log name and position), master host, username, password, port number, connection retry interval, and SSL option values. The default name for this file is master.info in the data directory.

  • --master-password=pass_val

    For a replication slave, the password of the MySQL account that it uses for connecting to the master server. If no password is given, the default is the empty password.

  • --master-port=port_num

    For a replication slave, the TCP/IP port to use for connecting to the master server. If no port is given, the default port number compiled into the server is used (usually 3306).

  • --master-retry-count=n

    For a replication slave, the number of times to attempt a connection to a master server before giving up.

  • --master-ssl (boolean)

    --master-ssl-ca=file_name
    --master-ssl-capath=dir_name
    --master-ssl-cert=file_name
    --master-ssl-cipher=str
    --master-ssl-key=file_name
    

    These options allow replication over secure connections. They are like the corresponding regular SSL options (--ssl, --ssl-ca, and so forth), but are used for setting up an SSL connection from the replication slave to the master. These options can be used as of MySQL 4.1.1.

  • --master-user=user_name

    For a replication slave, the username of the MySQL account that it uses for connecting to the master server. If no username is given, the default is test.

  • --max-binlog-dump-events=n

    This option is used by mysql-test-run for replication testing.

  • --relay-log=file_name

    For a replication slave, this option specifies the name of the relay log. (The slave I/O thread stores updates read from the master in the relay log, and the SQL thread reads the relay log for statements and executes them.) The default relay log name is HOSTNAME-relay-bin.nnnnnn in the data directory, where HOSTNAME is the name of the server host and nnnnnn is a sequence number that is incremented by one each time a new log is created.

  • --relay-log-index=file_name

    For a replication slave, the name of the relay log index file. The default name is HOSTNAME-relay-bin.index in the data directory, where HOSTNAME is the name of the server host.

  • --relay-log-info-file=file_name

    For a replication slave, the name of the relay log information file. The default name is relay-log.info in the data directory.

  • --replicate-do-db=db_name

    For a replication slave, replicate only the named database. To restrict replication to a set of databases, repeat the option once for each database name.

  • --replicate-do-table=db_name.tbl_name

    For a replication slave, replicate only the given table, which should be named in db_name.tbl_name format. To restrict replication to a set of tables, repeat the option once for each table name.

  • --replicate-ignore-db=db_name

    For a replication slave, do not replicate the named database. To ignore multiple databases, repeat the option once for each database name.

  • --replicate-ignore-table=db_name.tbl_name

    For a replication slave, do not replicate the named table. To ignore multiple tables, repeat the option once for each table name.

  • --replicate-rewrite-db=master_db->slave_db

    This option tells a replication slave to treat one database as another. Updates made to the original database master_db on the master server are replicated as updates to the database slave_db on the slave server. When given on the command line, the option value should be enclosed within quotes to prevent the command interpreter from treating the '>' character as an output redirection operator.

  • --replicate-same-server-id (boolean)

    If this option is enabled, the server will not skip replication events that contain its own server ID. This option is disabled by default to prevent replication loops, but can be enabled in certain special circumstances. This option was introduced in MySQL 4.1.2.

  • --replicate-wild-do-table=pattern

    For a replication slave, replicate only tables with names that match the given pattern. To restrict replication to a set of patterns, repeat the option once for each pattern.

  • --replicate-wild-ignore-table=pattern

    For a replication slave, do not replicate tables with names that match the given pattern. To ignore multiple patterns, repeat the option once for each pattern.

  • --report-host=host_name

    Report to the master server that the slave server host is host_name.

  • --report-password=pass_val

    Report to the master server that the slave server account password is pass_val.

  • --report-port=port_num

    Report to the master server that the slave server port is port_num.

  • --report-user=user_name

    Report to the master server that the slave server account name is user_name.

  • --rpl-recovery-rank=n

    This option is not used.

  • --server-id=n

    The replication server ID value. The value must be in the range from 1 to 2321 and it must be unique among communicating replication servers.

  • --show-slave-auth-info (boolean)

    Display the slave server username and password in the output of the SHOW SLAVE HOSTS statement.

  • --skip-slave-start

    Do not start the slave automatically. It must be started manually by issuing a START SLAVE statement.

  • --slave-load-tmpdir=dir_name

    The pathname to the directory used by a slave server for processing LOAD DATA statements. If this option is not specified, it defaults to the value of --tmpdir.

  • --slave-skip-errors=error_list

    The list of errors that a slave server should ignore rather than suspending replication if they occur. (However, it's usually better to determine what is causing problems so that you can resolve them rather than using this option to ignore them.) A value of all means all errors should be ignored. Otherwise, the value should be a list of one or more error numbers separated by commas.

  • --sporadic-binlog-dump-fail (boolean)

    This option is used by mysql-test-run for replication testing.

Variables for mysqld

To see the full help message that displays the system variable values that mysqld will use by default, use this command:

% mysqld --verbose --help

Do not use the --verbose option before MySQL 4.1.1.

To see what system variable values the currently executing mysqld is using, use this command:

% mysqladmin variables

You can also check the current system variable values by issuing a SHOW VARIABLES statement. Individual system variables are described in Appendix D, "System, Status, and User Variable Reference." System variable values can be set at startup time using the instructions given in "Setting Program Variables" earlier in this appendix. In addition, many system variables can be modified dynamically; for more information, see "Setting and Checking System Variable Values," in Chapter 11, and the entry for the SET statement in Appendix E.

    Team LiB
    Previous Section Next Section