mysqladmin
mysqladmin [options]command[command_options]
This utility allows you to perform MySQL server administration tasks from the command line. You can use it to check the server’s status and settings, flush tables, change passwords, shut down the server, and perform a few other administrative functions. This utility interacts with the MySQL server.
Here is an alphabetical list of options that you can give as the first argument to the utility:
--character-sets-dir=pathThis option specifies the directory that contains character sets.
--compress, -CThis option compresses data passed between the utility and the server, if compression is supported.
--connect_timeout=numberThis option sets the number of seconds a connection may be idle before it will time out.
--count=number,
-c numberThis option specifies the number of iterations of commands
to perform in conjunction with the --sleep
option.
--debug=options
filename, -#
options,
filenameThis option logs debugging information. The set of options
used by default is 'd:t:o,logname'. See Table 16-1 at the end of the list of
options under the mysqldump utility for an
explanation of these flags and others that may be used.
--debug-checkThis option writes debugging information to the log when the utility ends. It’s available as of version 5.1.21 of MySQL.
--debug-infoThis option adds debugging information and CPU and memory usage information to the log when the utility ends. It’s available as of version 5.1.21 of MySQL.
--default-character-sets-dir=pathThis option specifies the directory that contains the default character sets.
--force, -fThis option forces execution of the DROP
DATABASE statement and others despite error
messages.
--help, -?This option displays basic help information.
--host=host,
-h hostThis option specifies the name or IP address of the server for connection.
--no-beepThis option instructs the utility not to emit a warning sound for errors. It was added as of version 5.1.17 of MySQL.
--password[=password],
-p[password]This option provides the password to give to the server. No
spaces are allowed between the -p and the
password. If a password is not given, the user will be prompted
for one.
--port=port,
-P portThis option specifies the port on which to connect to the server. The default is 3306.
--relative, -rThis option displays the differences between values with
each iteration of commands issued with the
--sleep option.
--shutdown_timeout=numberThis option sets the number of seconds the client should wait before shutting down.
--silent, -sThis option tells the utility to exit without error messages if a connection to the server cannot be established.
--sleep=seconds,
-i secondsThis option specifies the number of seconds to wait between
the repeated execution of commands. The number of iterations is
set by the --count option.
--socket=filename,
-S filenameThis option provides the name of the server’s socket file.
--sslThis option specifies that secure SSL connections should be used. It requires the server to have SSL enabled.
--ssl-ca=pem_fileThis option specifies the name of the file (i.e., the pem file) containing a list of trusted SSL CAs.
--ssl-capath=pathThis option specifies the path to the trusted certificates file (i.e., the pem file).
--ssl-cert=filenameThis option specifies the name of the SSL certificate file to use for SSL connections.
--ssl-cipher=ciphersThis option gives a list of ciphers that may be used for SSL encryption.
--ssl-key=filenameThis option specifies the SSL key file to use for secure connections.
--ssl-verify-server-certThis option verifies the client’s certificate against the server’s certificate for the client at startup. It is available as of version 5.1.11 of MySQL.
--start-slaveThis option is issued on a slave server to start replication.
--stop-slaveThis option is issued on a slave server to stop replication.
--user=user,
-u userThis option specifies a MySQL user other than the current filesystem user.
--verbose, -vThis option displays more information.
--version, -VThis option displays the version of the utility.
--vertical, -EThis option displays output in a vertical format with a separate line for each column of data.
--wait[=number],
-w [number]This option instructs the utility to wait until it can connect to the server. It will retry once unless the number of times it is to retry is given with this option.
The main focus of mysqladmin is the
commands that perform administrative tasks. Commands are given as the
second argument. You can issue one or more commands on the same line.
Here is an alphabetical list of commands (with options for some) and an
explanation of each:
create
databaseThis command creates the new database specified.
debugThis command enables debugging of the utility. It writes debugging information to the error log.
drop
databaseThis command deletes the database specified.
extended-statusThis command displays the MySQL server’s extended status information.
flush-hostsThis command flushes all cached hosts.
flush-logsThis command flushes all logs.
flush-privilegesThis command reloads the grant tables.
flush-statusThis command flushes status variables.
flush-tablesThis command has the utility flush all tables.
flush-threadsThis command flushes the thread cache.
kill idThis command kills the server thread specified by an identifier. Additional threads may be given in a comma-separated list.
old-password
passwordThis command changes the password of the user currently connected to the server through the utility to the password given, but in the older encryption method prior to version 4.1 of MySQL.
password
passwordThis command changes the user’s password to the given
password. Only the password for the
user connecting to the server can be changed.
pingThis command determines whether the server is running.
processlistThis command displays a list of active server threads. With
the --verbose option, more information is
provided on each thread.
refreshThis command flushes all tables and reloads log files.
reloadThis command reloads the grant tables.
shutdownThis command shuts down the MySQL server.
start-slaveThis command starts a replication slave server.
statusThis command displays the server’s status.
stop-slaveThis command stops a replication slave server.
variablesThis command displays the variables and the values of the server.
versionThis command displays the version of the utility.