mysqladmin 命令详解
mysqladmin是一个执行管理操作的客户端程序。它可以用来检查服务器的配置和当前状态、创建和删除数据库等。
mysqladmin 工具的使用格式:
mysqladmin [option] command [command option] command ......
option 选项:
-c number 自动运行次数统计,必须和 -i 一起使用 -i number 间隔多长时间重复执行 -h --host=name Connect to host. 连接的主机名或iP -p --password[=name] 登录密码,如果不写于参数后,则会提示输入 -P --port=# Port number to use for connection. 指定数据库端口 -s --silent Silently exit if one can't connect to server. -S --socket=name Socket file to use for connection. 指定socket file -i --sleep=# Execute commands again and again with a sleep between. 间隔一段时间执行一次 -u --user=name User for login if not current user.登录数据库用户名 -v --verbose Write more information. 写更多的信息 -V --version Output version information and exit. 显示版本
例:每隔5s查看一次服务状态,重复5次
mysqladmin -u root -p -i 5 -c 5 status
mysqladmin Command
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 in current 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
mysqladmin示例:【注:密码和-p中间不要空格,但不建议直接明文密码还是输入为好。如:mysqladmin -u root -p status】
mysqladmin -u root -p password 123456 设置密码 mysqladmin -u root -p123456 status 查看状态,同show status mysqladmin -u root -p123456 extended-status 同show global status mysqladmin -u root -p123456 flush-logs 切割日志 mysqladmin -u root -p123456 processlist 查看执行的SQL语句信息。 mysqladmin -u root -p123456 processlist -i 1 每秒查看一次执行的SQL语句 mysqladmin -u root -p123456 shutdown 关闭mysql服务 mysqladmin -u root -p123456 variables 同show variables
mysqlshow -u root -p123456 显示所有数据库