Team LiB
Previous Section Next Section

mysqladmin

The mysqladmin client communicates with the MySQL server to perform a variety of administrative operations. You can use mysqladmin to obtain information from or control the operation of the server, set passwords, and create or drop databases.

Usage

mysqladmin [options] command ...

Standard Options Supported by mysqladmin

--character-sets-dir      --password                --silent
--compress                --pipe                    --socket
--debug                   --port                    --user
--default-character-set   --protocol                --verbose
--help                    --set-variable            --version
--host                    --shared-memory-base-name

--silent causes mysqladmin to exit silently if it cannot connect to the server. The --verbose option causes mysqladmin to print more information for a few commands. mysqladmin also supports the standard SSL options.

--default-character-set is supported as of MySQL 4.1.9.

Options Specific to mysqladmin

  • --count=n, -c n

    The number of iterations to make when --sleep is given.

  • --force, -f (boolean)

    This option has two effects. First, it causes mysqladmin not to ask for confirmation of the drop db_name command. Second, when multiple commands are specified on the command line, mysqladmin attempts to execute each command even if errors occur. Normally, mysqladmin exits after the first error.

  • --relative, -r (boolean)

    Show the difference between the current and previous values when used with --sleep. Currently, this option works only with the extended-status command.

  • --sleep=n, -i n

    Execute the commands named on the command line repeatedly with a delay of n seconds between each repetition.

  • --vertical, -E (boolean)

    This option is like --relative, but displays output vertically.

  • --wait[=n], -w[n]

    The number of times to wait and retry if a connection to the server cannot be established. The default value of n is 1 if no value is given. If n is specified after -w, there must be no intervening space or the value will not be interpreted correctly.

Variables for mysqladmin

The following mysqladmin variables can be set using the instructions given in "Setting Program Variables" earlier in this appendix.

  • connect_timeout

    The number of seconds to wait before timing out when attempting to connect to the server. The default value is 43,200.

  • shutdown_timeout

    For shutdown commands, the number of seconds to wait for a successful shutdown. The default value is 3,600.

mysqladmin Commands

Following any options on the command line, you can specify one or more of the following commands. Each command name can be shortened to a prefix, as long as the prefix is unambiguous. For example, processlist can be shortened to process or proc, but not to p.

Several of these commands have an equivalent SQL statement, as noted in the descriptions. For more information about the meaning of the SQL statements, see Appendix E, "SQL Syntax Reference."

  • create db_name

    Create a new database with the given name. This command is like the CREATE DATABASE db_name statement.

  • debug

    Instruct the server to dump debugging information.

  • drop db_name

    Delete the database with the given name, and any tables that may be in the database. Be careful with this command; you can't get the database back. mysqladmin asks for confirmation of this command unless the --force option was given. This command is like the DROP DATABASE db_name statement.

  • extended-status

    Display the names and values of the server's status variables. This command is like the SHOW STATUS statement.

  • flush-hosts

    Flush the host cache. This command is like the FLUSH HOSTS statement.

  • flush-logs

    Flush (close and reopen) the log files. This command is like the FLUSH LOGS statement.

  • flush-privileges

    Reload the grant tables. This command is like the FLUSH PRIVILEGES statement.

  • flush-status

    Clear the status variables. (This resets several counters to zero.) This command is like the FLUSH STATUS statement.

  • flush-tables

    Flush the table cache. This command is like the FLUSH TABLES statement.

  • flush-threads

    Flush the thread cache.

  • kill id,id,...

    Kill the server threads specified by the given identifier numbers. If you specify multiple numbers, the ID list should contain no spaces so that it will not be confused with another command following the kill command. To find out what threads are currently running, use mysqladmin processlist. This command is like issuing a KILL statement for each thread ID.

  • old-password new_password

    This command is like the password command except that it causes the password to be stored in the older (pre-MySQL 4.1) password-hashing format.

  • password new_password

    Change the password for the account that you use when invoking mysqladmin. (Being able to connect to the server using this account serves as verification that you know the current password.) The password will be set to new_password. This command is like the SET PASSWORD statement.

  • ping

    Check whether the MySQL server is running.

  • processlist

    Display a list of the currently executing server threads. This command is like the SHOW PROCESSLIST statement. With the --verbose option, this command is like SHOW FULL PROCESSLIST.

  • refresh

    This command flushes the table cache and the grant tables, and closes and reopens the log files. If the server is a replication master server, the command tells it to delete the binary logs listed in the binary log index file and to truncate the index. If the server is a slave server, the command tells it to forget its position in the master logs.

  • reload

    Reload the grant tables. This command is like the FLUSH PRIVILEGES statement.

  • shutdown

    Shut down the server.

  • start-slave

    Start a replication slave server. This command is like the START SLAVE statement.

  • status

    Display a short status message from the server.

  • stop-slave

    Stop a replication slave server. This command is like the STOP SLAVE statement.

  • variables

    Display the names and values of the server's variables. This command is like the SHOW GLOBAL VARIABLES. (There is no support for SHOW SESSION VARIABLES because that wouldn't make any sense.)

  • version

    Retrieve and display the server version information string. This is the same information that is returned by the VERSION() SQL function. (See Appendix C, "Operator and Function Reference.")

    Team LiB
    Previous Section Next Section