mysqladmin
Administer MySQL/MariaDB servers
SYNOPSIS
mysqladmin [options] command [arguments]
Common invocation examples:
mysqladmin --user=root --password status
mysqladmin -h localhost -u admin -p create new_database
mysqladmin ping
PARAMETERS
-h or --host=<hostname>
Connect to MySQL server on the given host.
-u or --user=<username>
MySQL user name to use when connecting to the server.
-p or --password[=<password>]
Password to use when connecting to the server. If not specified, mysqladmin prompts for it.
-P or --port=<port_num>
TCP/IP port number for the connection.
-S or --socket=<path>
For connections to localhost, the Unix socket file to use.
-s or --silent
Silent mode. Produce less output.
-v or --verbose
Verbose mode. Produce more output about what the program does.
--connect-timeout=<seconds>
The maximum number of seconds before connection timeout.
--debug[=<debug_options>]
Write a debugging log.
--force
Don't ask for confirmation for destructive commands like drop database. Use with extreme caution.
--ssl-ca=<path>
Path to a file in PEM format containing a list of trusted SSL Certificate Authorities.
--ssl-cert=<path>
Path to the client's X509 certificate in PEM format.
--ssl-key=<path>
Path to the client's X509 private key in PEM format.
DESCRIPTION
mysqladmin is a command-line client for performing administrative operations on a MySQL server. It provides a convenient way to execute common tasks such as checking the server's status, creating or dropping databases, reloading privilege tables, shutting down the server, and performing various diagnostic checks.
It connects to the MySQL server, executes the specified command, and then disconnects. This tool is essential for database administrators and developers needing to manage MySQL instances programmatically or from scripts without directly logging into the MySQL client console.
CAVEATS
Using mysqladmin requires appropriate MySQL user privileges for the operations being performed. For instance, dropping a database requires the DROP privilege for that database. Supplying passwords directly on the command line (e.g., -pMySecret) is insecure as it may be visible to other users via process lists (like ps) and stored in shell history files. It is recommended to use -p to be prompted for the password interactively.
COMMON MYSQLADMIN COMMANDS
The following are the most frequently used commands that can be passed as arguments to mysqladmin to perform specific actions:
ping: Checks if the MySQL server is alive.
status: Shows a short server status message.
version: Displays server version information.
shutdown: Shuts down the MySQL server. Requires SHUTDOWN privilege.
create databasename: Creates a new database. Requires CREATE privilege.
drop databasename: Drops (deletes) a database. This action is irreversible. Requires DROP privilege. Use with --force for non-interactive deletion.
reload: Reloads the grant tables (privileges). Same as flush-privileges. Requires RELOAD privilege.
flush-privileges: Reloads the grant tables (privileges). Same as reload.
flush-hosts: Flushes the host cache table.
flush-logs: Flushes all logs (binary, error, general, slow query).
processlist: Shows the currently running MySQL server processes. Requires PROCESS privilege.
HISTORY
mysqladmin has been a fundamental part of the MySQL distribution since its early versions. It was designed as a lightweight, command-line tool for essential server management, complementing the main mysql client. Its functionality and interface have remained remarkably consistent over decades, reflecting its core utility for quick administrative tasks.
SEE ALSO
mysql(1), mysqldump(1), mysqlcheck(1), mysqld(8)