>mysqladmin 工具的使用格式:

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

option 选项:

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

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

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

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

-#, --debug[=name] Output debug log. Often this is 'd:t:o,filename'.
-f, --force Don't ask for confirmation on drop database; with
multiple commands, continue even if an error occurs. 禁用错误,drop 数据库时不提示,执行多条命令时出错继续执行
-C, --compress Use compression in server/client protocol.
--character-sets-dir=name 字符集所在目录
Directory where character sets are.
--default-character-set=name 设置默认字符集
Set the default character set.
-?, --help Display this help and exit. 显示帮助

-h, --host=name Connect to host. 连接的主机名或iP
-p, --password[=name] 登录密码,如果不写于参数后,则会提示输入
Password to use when connecting to server. If password is
not given it's asked from the tty.
-P, --port=# Port number to use for connection. 指定数据库端口
--protocol=name The protocol of connection (tcp,socket,pipe,memory). 指定连接协议
-r, --relative Show difference between current and previous values when
used with -i. Currently works only with extended-status. 显示前后变化的值,必须结合- i

./mysqladmin -uroot -p -i 2 -r extended-status

假如此处显示的uptime 将永远是2,因为与之前取的结果比只相差2.

-O, --set-variable=name
Change the value of a variable. Please note that this
option is deprecated; you can set variables directly with
--variable-name=value.修改变量的值,该选项已经不再使用,请使用--variable-name=value 的方式修改变量值
-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. 显示版本

./mysql -uroot -p -V

-E, --vertical Print output vertically. Is similar to --relative, but
prints output vertically.
-w, --wait[=#] Wait and retry if connection is down. 如果连接断开,等待w 指定的时间后重试
--connect_timeout=#
--shutdown_timeout=#

1、查看服务器的状况:status

./mysql -uroot -p status

显示结果:

Uptime: 4883162 Threads: 1 Questions: 86 Slow queries: 0 Opens: 0 Flush tables: 1 Open tables: 18 Queries per second avg: 0.000

2.修改root 密码:

mysqladmin -u root -poldpassword password 'newpassword'

3.检查mysqlserver是否可用:

mysqladmin -uroot -p ping

显示结果:

mysqld is alive

4.查询服务器的版本

mysqladmin -uroot -p version

5.查看服务器状态的当前值:

mysqladmin -uroot -p extended-status

显示结果:

+-----------------------------------+----------+
| Variable_name | Value |
+-----------------------------------+----------+
| Aborted_clients | 12 |
| Aborted_connects | 300 |
| Binlog_cache_disk_use | 0 |
| Binlog_cache_use | 0 |
| Bytes_received | 23608 |
| .......

|Threads_created | 3 |
| Threads_running | 1 |
| Uptime | 4884294 |
+-----------------------------------+----------+

6.查询服务器系统变量值:

mysqladmin -uroot -p variables

显示结果:

+---------------------------------+----------------------------------------+
| Variable_name | Value |
+---------------------------------+----------------------------------------+
| auto_increment_increment | 1 |
| auto_increment_offset | 1 |
| automatic_sp_privileges | ON |
| back_log | 50 |
| basedir | /usr/local/mysql/ |

..

7.显示服务器所有运行的进程:

mysqladmin -uroot -p processlist

mysqladmin -uroot -p-i 1 processlist 每秒刷新一次

显示结果:

+-----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-----+------+-----------+----+---------+------+-------+------------------+
| 331 | root | localhost | | Query | 0 | | show processlist |
+-----+------+-----------+----+---------+------+-------+------------------+

8.创建数据库

./mysqladmin -uroot -p create daba-test

验证:

./mysql -uroot -p 登录后:show databases;

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

./mysqlshow -uroot -p

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

./mysqlshow -uroot -p daba-test

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

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

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

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

13. 删除数据库 daba-test

./mysqladmin -uroot -p drop daba-test

14. 重载权限信息

./mysqladmin -uroot -p reload

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

./mysqladmin -uroot -p refresh

16.使用安全模式关闭数据库

./mysqladmin -uroot -p shutdown

You can also use “/etc/rc.d/init.d/mysqld stop” to shutdown the server. To start the server, execute “/etc/rc.d/init.d/mysql start”--如果不是以服务来运行则这两条命令无效

17.mysqladmin flush commands

# mysqladmin -u root -ptmppassword flush-hosts
# mysqladmin -u root -ptmppassword flush-logs
# mysqladmin -u root -ptmppassword flush-privileges
# mysqladmin -u root -ptmppassword flush-status
# mysqladmin -u root -ptmppassword flush-tables
# mysqladmin -u root -ptmppassword flush-threads

•flush-hosts: Flush all information in the host cache.
•flush-privileges: Reload the grant tables (same as reload).
•flush-status: Clear status variables.
•flush-threads: Flush the thread cache.
18 .mysqladmin 执行kill 进程:

./mysqladmin -uroot -p processlist

./mysqladmin -uroot -p kill idnum

19.停止和启动MySQL replication on a slave server

mysqladmin -u root -p stop-slave

mysqladmin -u root -p start-slave

20 .同时执行多个命令

mysqladmin -u root -p process status version

关于 mysqladmin的更多相关文章

  1. MySQL服务 - 客户端工具mysql及mysqladmin使用介绍

    mysql客户端: mysql工具是MySQL官方提供的连接工具,用户可以通过mysql连接到mysqld上进行一系列的SQL操作.mysql工具有两种模式:交互模式和命令行模式.交互模式指令需要连接 ...

  2. mysql连接报错 Host ‘xxx’is blocked because of many connection errors;unblock with 'mysqladmin flush-hosts'

    程序无法连接MySQL,提示:  null, message from server: "Host '192.168.6.68' is blocked because of many con ...

  3. mysql下mysqladmin日常管理命令总结

    mysqladmin 工具的使用格式:mysqladmin [option] command [command option] command ......参数选项:-c number 自动运行次数统 ...

  4. 使用mysqladmin ext了解MySQL运行状态【转】

    摘要: mysqladmin是 MySQL一个重要的客户端,最常见的是使用它来关闭数据库,除此,该命令还可以了解MySQL运行状态.进程信息.进程杀死等.本文介绍一下如何使用 mysqladmin e ...

  5. mysqladmin note

    hr,fresh meat!! --------------------------------------------------- 15 Practical Usages of Mysqladmi ...

  6. MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 解决方法

    环境:linux,mysql5.5.21 错误:Host is blocked because of many connection errors; unblock with 'mysqladmin ...

  7. MySQL忘记密码,或:root密码重置报错:mysqladmin: connect to server at 'localhost' failed的解决方案

    MySQL root密码重置报错:mysqladmin: connect to server at 'localhost' failed的解决方案   1  登陆失败,mysqladmin修改密码失败 ...

  8. cut mysqladmin

    [root@86 ~]# mysqladmin -uroot -p123456 -S /tmp/mysql.sock status Uptime: 112403 Threads: 17 Questio ...

  9. Using SHOW PROCESSLIST and mysqladmin debug Output in Conjunction with SHOW INNODB STATUS

    When InnoDB appears hung, I know the natural reaction is to check SHOW ENGINE INNODB STATUS. In fact ...

  10. MySQLAdmin用法

    MySQLAdmin用法用于执行管理性操作.语法是:shell> mysqladmin [OPTIONS] command [command-option] command ...通过执行mys ...

随机推荐

  1. CMakeLists实战解读--YouCompleteMe

    原文转载自:Ricky.K http://www.cnblogs.com/rickyk/p/3877238.html 个人一直有一个想法,就是想出一系列关于CMakeLists.txt国外经典例子的实 ...

  2. PHP 魔术方法 __construct __destruct (一)

    慢慢长寻夜,明月高空挂 __construct() - 在每次创建新对象时先调用此方法 __destruct()  - 对象的所有引用都被删除或者当对象被显式销毁时执行 <?php /** * ...

  3. 解决svn “clean up" 失败

    解决方法:清空svn的队列 1.下载sqlite3.exe 2.找到你项目的.svn文件,查看是否存在wc.db 3.将sqlite3.exe放到.svn的同级目录 4.启动cmd执行sqlite3 ...

  4. Spark Streaming揭秘 Day25 StreamingContext和JobScheduler启动源码详解

    Spark Streaming揭秘 Day25 StreamingContext和JobScheduler启动源码详解 今天主要理一下StreamingContext的启动过程,其中最为重要的就是Jo ...

  5. 通过 struct 成员地址 获取 struct 结构体地址

    1. 问题描述: 现在定义了一个结构体: struct Foo { int a; int b; }; Foo foo; 假如由于函数传参等原因,现在程序只能拿到 foo.b 的地址,这时想通过某种方法 ...

  6. javaweb 在netbeans 上的部署问题

    最近用netbeans去部署开发 javaweb程序!现总结一下自己的安装开发过程. 第一,在官网上下载netbeans时,有自带的tomcat,可以直接使用这个服务器,在我这儿这个自带的tomcat ...

  7. gridView AspNetPager 翻页时 弹出窗体关闭报错

    gridView AspNetPager 翻页后,你右击刷新或F5会发现弹出一个刷新页面. 这是因为默认翻页都是用dopostback方式回发的.因为这时的页面已经不是原来的页面.所以会弹出提示. 这 ...

  8. Unity3D游戏开发——Asset Server搭建

    本系列文章由 Amazonzx 编写,欢迎转载,转载请注明出处. http://blog.csdn.net/amazonzx/article/details/7980117 Asset Server是 ...

  9. NGUI系列教程十(Scroll View实现触摸滚动相册效果)

    NGUI中提供了两种Scroll View 一种是通过手指或鼠标滑动视图时移动平面物体,另一种则是直接移动摄像机,他们各有各的好处.但是NGUI提供的Scroll View很难实现类似Android ...

  10. Web Api 控制器

    Web Api 控制器 文档目录 本节内容: 简介 AbpApiController 基类 本地化 其它 过滤 审计日志 授权 防伪造过滤 工作单元 结果包装和异常处理 结果缓存 验证 模块绑定器 简 ...