The mysqladmin utility 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.
mysqladmin [options] command ...
--character-sets-dir --password --socket --compress --pipe --user --debug --port --verbose --help --set-variable --version --host --silent
--silent causes mysqladmin to exit silently if it cannot connect to the server. --verbose was added in MySQL 3.22.30. It causes mysqladmin to print more information for a few commands. --character-sets-dir was added in 3.23.21. As of MySQL 4, mysqladmin also supports the standard SSL options.
--count=n, -c n
The number of iterations to make when --sleep is given. This option was introduced in MySQL 4.0.3.
--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 will exit 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.
--timeout=n, -t n
Wait n seconds before timing out when attempting to connect to the server. This option was introduced in MySQL 3.22.1 and removed in 3.23.29 when the connect_timeout variable was introduced.
--vertical, -E (boolean)
This option is like --relative but displays output vertically. It was introduced in MySQL 3.23.14.
--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.
The following mysqladmin variables can be set using the instructions in the "Setting Program Variables" section earlier in this appendix.
connect_timeout
The number of seconds to wait before timing out when attempting to connect to the server. This variable was introduced in MySQL 3.23.29 when the --timeout option was removed.
shutdown_timeout
For shutdown commands, the number of seconds to wait for a successful shutdown. This variable was introduced in MySQL 3.23.34.
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 D, "SQL Syntax Reference."
create db_name
Create a new database with the given name. This command is like the CREATE DATABASE db_name statement.
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.
debug
Instruct the server to dump debugging information.
extended-status
Display the names and values of the server's status variables. This command is like the SHOW STATUS statement. It was introduced in MySQL 3.22.10.
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. It was introduced in MySQL 3.22.12.
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 for 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.
password new_password
Change the password for 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 update 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 SLAVE START statement. It was introduced in MySQL 3.23.16.
status
Display a short status message from the server.
stop-slave
Stop a replication slave server. This command is like the SLAVE STOP statement. It was introduced in MySQL 3.23.16.
variables
Display the names and values of the server's variables. This command is like the SHOW VARIABLES statement. As of MySQL 4.0.3, which supports the notion of both global and session variables, this command is like 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() function (see Appendix C, "Operator and Function Reference").