mysqladmin 工具的使用格式:

mysqladmin [option] command [command option] command ......

option 选项:

-c  number 自动运行次数统计,必须和 -i 一起使用

-i   number 间隔多长时间重复执行

MySQLAdmin用法
用于执行管理性操作。语法是:
shell> mysqladmin [OPTIONS] command [command-option] command ...
通过执行mysqladmin --help,你可以得到你mysqladmin的版本所支持的一个选项列表。
目前mysqladmin支持下列命令:
create databasename             创建一个新数据库
drop databasename               删除一个数据库及其所有表
extended-status                 给出服务器的一个扩展状态消息
flush-hosts                     洗掉所有缓存的主机
flush-logs                      洗掉所有日志 
flush-tables                    洗掉所有表 
flush-privileges                再次装载授权表(同reload) 
kill id,id,...                  杀死mysql线程 
password                        新口令,将老口令改为新口令
ping                            检查mysqld是否活着 
processlist                     显示服务其中活跃线程列表
reload                          重载授权表 
refresh                         洗掉所有表并关闭和打开日志文件
shutdown                        关掉服务器 
status                          给出服务器的简短状态消息
variables                       打印出可用变量
version                         得到服务器的版本信息

示例:

--每个两秒查看一次服务器的状态,总共重复5次

./mysqladmin -uroot -p  -i 2 -c 5 status

--修改密码

mysqladmin -uroot -ptest passoword 新密码 --不要在新密码后添加分号

--判断服务是否启动

[root@localhost bin]# mysqladmin -uroot -predhat ping
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqld is alive
[root@localhost bin]#

--关闭服务

mysqladmin -utest -ptest1 shutdown

--查看mysql版本

[root@localhost bin]# mysqladmin -uroot -predhat version
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin Ver 8.42 Distrib 5.7.17, for linux-glibc2.5 on x86_64
Copyright (c) 2000, 2016, 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.17-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 5 hours 55 min 56 sec Threads: 6 Questions: 1936 Slow queries: 21 Opens: 840 Flush tables: 1 Open tables: 124 Queries per second avg: 0.090
[root@localhost bin]#

--查看所有的全局变量

mysqladmin -utest -ptest1 variables

--mysql的状态

[root@localhost bin]# mysqladmin -uroot -predhat status
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Uptime: 21197 Threads: 6 Questions: 1932 Slow queries: 21 Opens: 840 Flush tables: 1 Open tables: 124 Queries per second avg: 0.091
[root@localhost bin]#

--查询所有mysql连接的客户端

[root@localhost bin]# mysqladmin -uroot -predhat processlist
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
+----+------+---------------------+--------------+---------+-------+----------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+---------------------+--------------+---------+-------+----------+------------------+
| 5 | root | 192.168.0.206:64294 | | Sleep | 14779 | | |
| 8 | root | 192.168.0.206:64297 | | Sleep | 21287 | | |
| 10 | root | localhost | | Sleep | 2430 | | |
| 22 | root | 192.168.0.206:54750 | account_data | Sleep | 3160 | | |
| 23 | root | 192.168.0.206:54751 | account_data | Sleep | 14764 | | |
| 32 | root | localhost | | Query | 0 | starting | show processlist |
+----+------+---------------------+--------------+---------+-------+----------+------------------+
[root@localhost bin]#

--杀掉某个客户端的链接

C:\>mysqladmin -utest -ptest1 kill 7,8
C:\>mysqladmin -utest -ptest1 processlist
+----+------+----------------+----+---------+------+-------+------------------+
| Id | User | Host           | db | Command | Time | State | Info             |
+----+------+----------------+----+---------+------+-------+------------------+
| 12 | test | localhost:3112 |    | Query   | 0    |       | show processlist |
+----+------+----------------+----+---------+------+-------+------------------+

--创建数据库和删除数据库

C:\>mysqladmin -utest -ptest1 create aaa

C:\>mysqladmin -utest -ptest1 drop aaa
Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.
Do you really want to drop the 'aaa;' database [y/N] y
Database "aaa;" dropped

--查询服务器拓展的状态

mysqladmin -utest -ptest1 extended-status

--重载授权表

mysqladmin -utest -ptest1 reload

mysqladmin -utest -ptest1 flush-privileges

--刷新所有表缓存,并关闭和打开log

./mysqladmin -uroot -p refresh

--使用安全模式关闭数据库

./mysqladmin -uroot -p shutdown

--显示服务器上的所有数据库

./mysqlshow -uroot -p

--显示数据库daba-test下有些什么表:

./mysqlshow -uroot -p daba-test

--统计daba-test 下数据库表列的汇总

./mysqlshow -uroot -p daba-test -v

--统计daba-test 下数据库表的列数和行数

 ./mysqlshow -uroot -p daba-test -v -v

mysqladmin命令用法的更多相关文章

  1. Linux mysqladmin 命令

    mysqladmin命令可以用来设置或修改 MySQL 密码,常见用法如下: [root@localhost ~]$ mysqladmin -uroot password 'newPass' # 在无 ...

  2. systemctl命令用法详解

    systemctl命令用法详解系统环境:Fedora 16binpath:/bin/systemctlpackage:systemd-units systemctl enable httpd.serv ...

  3. cpio命令用法

    [转自]流浪妖精のSKY    http://www.cnitblog.com/flutist1225/articles/18974.html cpio命令用法 cpio命令     利用cpio 可 ...

  4. shutdown命令用法

    首先我们先创建一个txt文件,添加shutdown -r -f -t 0 ,文件点击另存为,选择所有类型,保存格式为“重启.bat”文件. 说明:shutdown命令用法: /r         关闭 ...

  5. linux中comm命令用法

    linux系统中comm命令用法详解 linux系统下的comm命令是一个非常实用的文件对比命令. comm命令功能:   选择或拒绝两个已排序的文件的公共的行. comm命令语法:comm [-12 ...

  6. Ubuntu kill命令用法详解

    转自:Ubuntu kill命令用法详解 1. kill   作用:根据进程号杀死进程   用法: kill [信号代码] 进程ID   root@fcola:/# ps -ef | grep sen ...

  7. install 命令用法详解

    install 命令用法详解 http://man.linuxde.net/install install命令的作用是安装或升级软件或备份数据,它的使用权限是所有用户.install命令和cp命令类似 ...

  8. which、whereis、locate、find 命令用法

    which.whereis.locate.find 命令用法   大部分转自http://312788172.iteye.com/blog/730280,有修改 我们经常在linux要查找某个文件,但 ...

  9. sed命令用法详解

    sed命令用法 sed是一种流编辑器,它是文本处理中非常有用的工具,能够完美的配合正则表达式使用,功能不同凡响.处理时,把当前处理的行存储在临时缓冲区中,称为『模式空间』(pattern space) ...

随机推荐

  1. ElasticSearch(二十一)正排和倒排索引

    1.区别 搜索的时候,要依靠倒排索引:排序的时候,需要依靠正排索引,看到每个document的每个field,然后进行排序,所谓的正排索引,其实就是doc values 在建立索引的时候,一方面会建立 ...

  2. Android笔记之WebView加载网页的进度回调

    wv.setWebChromeClient(new WebChromeClient(){ @Override public void onProgressChanged(WebView view, i ...

  3. 页游手游服务器(二)c支持mysql

    上一篇说的是liua的net拓展,这一篇说lua的sql拓展,准确说是mysql拓展,这里推荐下postgre,比mysql好用,支持数组,各种好,不过腾讯平台不支持,所以你的公司要和腾讯合作,掂量下 ...

  4. python基础20 -------python中的异常处理

    一.python程序中的会出现的错误. 1.语法错误:这种错误根本过不了python解释器的语法检测阶段,必须在程序执行之前进行改正. 2.逻辑错误:这种错误虽然过了语法检测阶段但是程序在执行的过程中 ...

  5. afinal 文件上传、下载、图片加载实例

    // Afinal框架讲解 public class AfinalActivity extends FinalActivity { @ViewInject(id=R.id.bt_afinal_load ...

  6. J.U.C重入锁

    ReentrantLock重入锁 ReentrantLock是Java并发包中互斥锁,它有公平锁和非公平锁两种实现方式, 重入的意思就是,如果已经获得了锁,如果执行期间还需要获得这个锁的话,会直接获得 ...

  7. leetcode 889. Spiral Matrix III

    On a 2 dimensional grid with R rows and C columns, we start at (r0, c0) facing east. Here, the north ...

  8. 奥森图标和CSS特殊字体使用方法

    作为第一篇博文,写这个 我快要被气炸,好吧,废话不说了 昨天在项目中发现有很多这些Awesome图标 也在网上找了下Font Awesome下载后这些文件,现在的版本是4.2,Font Awesome ...

  9. Spring层面的事务管理

    事务管理方式 1. 编程式事务管理 2. 声明式事务管理 建立于AOP之上,对指定的方法执行前后进行拦截,即在方法执行前开始或加入一个事务,执行完毕后根据结果提交或回滚事务. 方式: a. 配置文件中 ...

  10. hd acm1008

    Problem Description The highest building in our city has only one elevator. A request list is made u ...