mysqladmin 是一个服务器端的管理程序。
调用方式:
mysqladmin [options] command [command-arg] [command [command-arg]] ...
mysqladmin支持以下命令:
create/drop db_name
创建/删除数据库
flush-logs
刷新日志
flush-privileges
刷新权限
flush-status
清空status变量
flush-tables
刷新所有的表
kill id,id
杀掉服务器线程,多个线程之间用逗号隔开,不能有空格,且用户必须要有SPUER权限
password new_password
设置新的密码,如果密码中有特殊字符或者空格,需要双引号(在linux上)
ping
检查服务器是否可用。
[root@centos7 data]# mysqladmin -uroot -pMysql5.7 ping
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqld is alive
processlist
显示服务器线程列表,跟SHOW PROCESSLIST语句相同
[root@centos7 data]# mysqladmin -uroot -pMysql5.7 processlist
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
+----+------+-----------+----+---------+------+----------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+----+---------+------+----------+------------------+
| 13 | root | localhost | | Query | 0 | starting | show processlist |
+----+------+-----------+----+---------+------+----------+------------------+
reload
重载授权表
refresh
刷新所有的表,关闭并重新打开日志文件。
shutdown
关闭服务器
start-slave
启动主从复制的从库
status
显示简单的服务器状态信息
[root@centos7 data]# mysqladmin -uroot -pMysql5.7 status
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Uptime: 73652 Threads: 1 Questions: 26 Slow queries: 0 Opens: 113 Flush tables: 1 Open tables: 106 Queries per second avg: 0.000
version
显示服务器版本信息
[root@centos7 data]# mysqladmin -uroot -pMysql5.7 version
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin Ver 8.42 Distrib 5.7.30, for linux-glibc2.12 on x86_64
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.7.30-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 27 min 43 sec
Threads: 1 Questions: 4 Slow queries: 0 Opens: 108 Flush tables: 1 Open tables: 101 Queries per second avg: 0.002
mysqladmin可以读取的选项组为[client],[mysqladmin]
mysqladmin 选项
—bind-address
如果一个电脑有多个网络接口,使用指定的接口去访问服务器
—host,-h
—password,-p
—port
—socket,-S
