Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 38.5Mb
PDF (A4) - 38.5Mb
PDF (RPM) - 37.8Mb
HTML Download (TGZ) - 10.3Mb
HTML Download (Zip) - 10.3Mb
HTML Download (RPM) - 9.0Mb
Man Pages (TGZ) - 197.5Kb
Man Pages (Zip) - 306.2Kb
Info (Gzip) - 3.5Mb
Info (Zip) - 3.5Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  /  ...  /  mysqladmin — Client for Administering a MySQL Server

4.5.2 mysqladmin — Client for Administering a MySQL Server

mysqladmin is a client for performing administrative operations. You can use it to check the server's configuration and current status, to create and drop databases, and more.

Invoke mysqladmin like this:

shell> mysqladmin [options] command [command-arg] [command [command-arg]] ...

mysqladmin supports the following commands. Some of the commands take an argument following the command name.

  • create db_name

    Create a new database named db_name.

  • debug

    Tell the server to write debug information to the error log. The connected user must have the SUPER privilege. Format and content of this information is subject to change.

    This includes information about the Event Scheduler. See Section 23.4.5, “Event Scheduler Status”.

  • drop db_name

    Delete the database named db_name and all its tables.

  • extended-status

    Display the server status variables and their values.

  • flush-hosts

    Flush all information in the host cache.

  • flush-logs [log_type ...]

    Flush all logs.

    As of MySQL 5.7.5, the mysqladmin flush-logs command permits optional log types to be given, to specify which logs to flush. Following the flush-logs command, you can provide a space-separated list of one or more of the following log types: binary, engine, error, general, relay, slow. These correspond to the log types that can be specified for the FLUSH LOGS SQL statement.

  • flush-privileges

    Reload the grant tables (same as reload).

  • flush-status

    Clear status variables.

  • flush-tables

    Flush all tables.

  • flush-threads

    Flush the thread cache.

  • kill id,id,...

    Kill server threads. If multiple thread ID values are given, there must be no spaces in the list.

    To kill threads belonging to other users, the connected user must have the SUPER privilege.

  • old-password new_password

    This is like the password command but stores the password using the old (pre-4.1) password-hashing format. (See Section, “Password Hashing in MySQL”.)

    This command was removed in MySQL 5.7.5.

  • password new_password

    Set a new password. This changes the password to new_password for the account that you use with mysqladmin for connecting to the server. Thus, the next time you invoke mysqladmin (or any other client program) using the same account, you will need to specify the new password.


    Setting a password using mysqladmin should be considered insecure. On some systems, your password becomes visible to system status programs such as ps that may be invoked by other users to display command lines. MySQL clients typically overwrite the command-line password argument with zeros during their initialization sequence. However, there is still a brief interval during which the value is visible. Also, on some systems this overwriting strategy is ineffective and the password remains visible to ps. (SystemV Unix systems and perhaps others are subject to this problem.)

    If the new_password value contains spaces or other characters that are special to your command interpreter, you need to enclose it within quotation marks. On Windows, be sure to use double quotation marks rather than single quotation marks; single quotation marks are not stripped from the password, but rather are interpreted as part of the password. For example:

    shell> mysqladmin password "my new password"

    In MySQL 5.7, the new password can be omitted following the password command. In this case, mysqladmin prompts for the password value, which enables you to avoid specifying the password on the command line. Omitting the password value should be done only if password is the final command on the mysqladmin command line. Otherwise, the next argument is taken as the password.


    Do not use this command used if the server was started with the --skip-grant-tables option. No password change will be applied. This is true even if you precede the password command with flush-privileges on the same command line to re-enable the grant tables because the flush operation occurs after you connect. However, you can use mysqladmin flush-privileges to re-enable the grant table and then use a separate mysqladmin password command to change the password.

  • ping

    Check whether the server is available. The return status from mysqladmin is 0 if the server is running, 1 if it is not. This is 0 even in case of an error such as Access denied, because this means that the server is running but refused the connection, which is different from the server not running.

  • processlist

    Show a list of active server threads. This is like the output of the SHOW PROCESSLIST statement. If the --verbose option is given, the output is like that of SHOW FULL PROCESSLIST. (See Section, “SHOW PROCESSLIST Syntax”.)

  • reload

    Reload the grant tables.

  • refresh

    Flush all tables and close and open log files.

  • shutdown

    Stop the server.

  • start-slave

    Start replication on a slave server.

  • status

    Display a short server status message.

  • stop-slave

    Stop replication on a slave server.

  • variables

    Display the server system variables and their values.

  • version

    Display version information from the server.

All commands can be shortened to any unique prefix. For example:

shell> mysqladmin proc stat
| Id | User  | Host      | db | Command | Time | State | Info             |
| 51 | monty | localhost |    | Query   | 0    |       | show processlist |
Uptime: 1473624  Threads: 1  Questions: 39487
Slow queries: 0  Opens: 541  Flush tables: 1
Open tables: 19  Queries per second avg: 0.0268

The mysqladmin status command result displays the following values:

  • Uptime

    The number of seconds the MySQL server has been running.

  • Threads

    The number of active threads (clients).

  • Questions

    The number of questions (queries) from clients since the server was started.

  • Slow queries

    The number of queries that have taken more than long_query_time seconds. See Section 5.4.5, “The Slow Query Log”.

  • Opens

    The number of tables the server has opened.

  • Flush tables

    The number of flush-*, refresh, and reload commands the server has executed.

  • Open tables

    The number of tables that currently are open.

If you execute mysqladmin shutdown when connecting to a local server using a Unix socket file, mysqladmin waits until the server's process ID file has been removed, to ensure that the server has stopped properly.

mysqladmin supports the following options, which can be specified on the command line or in the [mysqladmin] and [client] groups of an option file. For information about option files used by MySQL programs, see Section 4.2.6, “Using Option Files”.

Table 4.11 mysqladmin Options

--bind-addressUse specified network interface to connect to MySQL Server  
--compressCompress all information sent between client and server  
--connect_timeoutNumber of seconds before connection timeout  
--countNumber of iterations to make for repeated command execution  
--debugWrite debugging log  
--debug-checkPrint debugging information when program exits  
--debug-infoPrint debugging information, memory, and CPU statistics when program exits  
--default-authAuthentication plugin to use  
--default-character-setSpecify default character set  
--defaults-extra-fileRead named option file in addition to usual option files  
--defaults-fileRead only named option file  
--defaults-group-suffixOption group suffix value  
--enable-cleartext-pluginEnable cleartext authentication plugin  
--forceContinue even if an SQL error occurs  
--helpDisplay help message and exit  
--hostConnect to MySQL server on given host  
--login-pathRead login path options from .mylogin.cnf  
--no-beepDo not beep when errors occur  
--no-defaultsRead no option files  
--passwordPassword to use when connecting to server  
--pipeOn Windows, connect to server using named pipe  
--plugin-dirDirectory where plugins are installed  
--portTCP/IP port number for connection  
--print-defaultsPrint default options  
--protocolConnection protocol to use  
--relativeShow the difference between the current and previous values when used with the --sleep option  
--secure-authDo not send passwords to server in old (pre-4.1) format5.
--shared-memory-base-nameThe name of shared memory to use for shared-memory connections  
--show-warningsShow warnings after statement execution5.7.2 
--shutdown_timeoutThe maximum number of seconds to wait for server shutdown  
--silentSilent mode  
--sleepExecute commands repeatedly, sleeping for delay seconds in between  
--socketFor connections to localhost, the Unix socket file to use  
--sslEnable encrypted connection  
--ssl-caFile that contains list of trusted SSL Certificate Authorities  
--ssl-capathDirectory that contains trusted SSL Certificate Authority certificate files  
--ssl-certFile that contains X509 certificate  
--ssl-cipherList of permitted ciphers for connection encryption  
--ssl-crlFile that contains certificate revocation lists  
--ssl-crlpathDirectory that contains certificate revocation list files  
--ssl-keyFile that contains X509 key  
--ssl-modeSecurity state of connection to server5.7.11 
--ssl-verify-server-certVerify host name against server certificate Common Name identity  
--tls-versionProtocols permitted for encrypted connections5.7.10 
--userMySQL user name to use when connecting to server  
--verboseVerbose mode  
--versionDisplay version information and exit  
--verticalPrint query output rows vertically (one line per column value)  
--waitIf the connection cannot be established, wait and retry instead of aborting  

You can also set the following variables by using --var_name=value.

  • connect_timeout

    The maximum number of seconds before connection timeout. The default value is 43200 (12 hours).

  • shutdown_timeout

    The maximum number of seconds to wait for server shutdown. The default value is 3600 (1 hour).

User Comments
Sign Up Login You must be logged in to post a comment.