This section provides a quick introduction of mysqladmin, the client tool managing MySQL servers. You can run mysqladmin on a remote system to check the status of the MySQL server or shutdown the server.
What Is mysqladmin?
mysqladmin is a client tool program for database server administrators to manage a MySQL server remotely.
The syntax to run mysqladmin is:
mysqladmin version 5.0 supports about 23 commands. You can get a list of supported commands by:
\mysql\bin\mysqladmin
\mysql\bin\mysqladmin Ver 8.41 Distrib 5.0.45, for Win32 on ia32
Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free
software, and you are welcome to modify and redistribute it under the
GPL license
Administration program for the mysqld daemon.
Usage: \mysql\bin\mysqladmin [OPTIONS] command command....
-c, --count=# Number of iterations to make. This works with -i
(--sleep) only.
-#, --debug[=name] Output debug log. Often this is 'd:t:o,filename'
...
Default options are read from the following files in the given order:
C:\my.ini C:\my.cnf C:\WINDOWS\my.ini C:\WINDOWS\my.cnf
C:\mysql\my.ini C:\mysql\my.cnf
The following groups are read: mysqladmin client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit
--no-defaults Don't read default options from any options file
--defaults-file=# Only read default options from the given file #
--defaults-extra-file=# Read this file after the global files are read
Where command is a one or more of: (Commands may be shortened)
create databasename Create a new database
debug Instruct server to write debug information
to log
drop databasename Delete a database and all its tables
extended-status Gives an extended status message from the
server
flush-hosts Flush all cached hosts
flush-logs Flush all logs
flush-status Clear status variables
flush-tables Flush all tables
flush-threads Flush the thread cache
flush-privileges Reload grant tables (same as reload)
kill id,id,... Kill mysql threads
password new-password Change old password to new-password, MySQL 4.1
hashing.
old-password new-password Change old password to new-password in old
format.
ping Check if mysqld is alive
processlist Show list of active threads in server
reload Reload grant tables
refresh Flush all tables and close and open logfiles
shutdown Take server down
status Gives a short status message from the server
start-slave Start slave
stop-slave Stop slave
variables Prints variables available
version Get version info from server
Two options are important to run mysqladmin, --host=name and --user=name.
These options allows you to specify the host name where the MySQL server is running,
the user name to be used to access the server.
Here are some examples of using mysqladmin to manage the MySQL server running on my local host with
"root" as the user name:
\mysql\bin\mysqladmin --host=localhost ping
\mysql\bin\mysqladmin: connect to server at 'localhost' failed
error: Access denied for user 'ODBC'@'localhost' (using password: NO)
\mysql\bin\mysqladmin --host=localhost --user=root ping
mysqld is alive
\mysql\bin\mysqladmin --host=localhost --user=root status
Uptime: 26233 Threads: 1 Questions: 19 Slow queries: 0 Opens: 12
Flush tables: 1 Open tables: 0 Queries per second avg: 0.001
\mysql\bin\mysqladmin --host=localhost --user=root processlist
+----+------+----------------+---------+------+------------------+
| Id | User | Host | Command | Time | Info |
+----+------+----------------+---------+------+------------------+
| 15 | root | localhost:3453 | Query | 0 | show processlist |
+----+------+----------------+---------+------+------------------+
\mysql\bin\mysqladmin --host=localhost --user=root shutdown
\mysql\bin\mysqladmin --host=localhost --user=root ping
\mysql\bin\mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to MySQL server on 'localhost' (10061)'
Check that mysqld is running on localhost and that the port is 3306.
You can check this by doing 'telnet localhost 3306'