MySQL Study之--mysqladmin工具应用

本文介绍了MySQLAdmin工具的基本用法,包括检查MySQL服务器的状态、版本、进程等信息,以及如何使用该工具进行数据库的创建与删除操作。此外还展示了如何刷新MySQL服务器的各种缓存和日志。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

MySQL Study之--mysqladmin工具应用

1、查看mysql server是否启动

[root@rh64 ~]# mysqladmin -u root -p ping

Enter password: 

mysqld is alive

2、查看mysql server版本

[root@rh64 ~]# mysqladmin -u root -p version
Enter password: 
mysqladmin  Ver 8.42 Distrib 5.6.25-73.1, for Linux on x86_64
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, 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.6.25-73.1-log
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/lib/mysql/mysql.sock
Uptime:                 1 min 33 sec
Threads: 1  Questions: 10  Slow queries: 0  Opens: 67  Flush tables: 1  Open tables: 60  Queries per second avg: 0.107
3、查看mysql server状态
[root@rh64 ~]# mysqladmin -u root -p status

Enter password: 

Uptime: 156  Threads: 1  Questions: 13  Slow queries: 0  Opens: 67  Flush tables: 1  Open tables: 60  Queries per second avg: 0.083

4、查看mysql server扩展信息

[root@rh64 ~]# mysqladmin -u root -p extended-status
Enter password: 
+-----------------------------------------------+-------------+
| Variable_name                                 | Value       |
+-----------------------------------------------+-------------+
| Aborted_clients                               | 0           |
| Aborted_connects                              | 1           |
| Binlog_snapshot_file                          |             |
| Binlog_snapshot_position                      | 0           |
| Binlog_cache_disk_use                         | 0           |
| Binlog_cache_use                              | 0           |
| Binlog_stmt_cache_disk_use                    | 0           |
| Binlog_stmt_cache_use                         | 0           |
......
5、查看mysql server变量信息
[root@rh64 ~]# mysqladmin -u root -p variables 


------------------------------------------------------+
| auto_increment_increment                               | 1                                                      
| auto_increment_offset                                  | 1                                                                                                                                                                                                               
| autocommit                                             | ON                                                                                                                                                                                                                 
| automatic_sp_privileges                                | ON                                                                                                                                                                                                          
| avoid_temporal_upgrade                                 | OFF    
6、查看mysql server进程
[root@rh64 ~]# mysqladmin -u root -p processlist

Enter password: 
+----+------+-----------+----+---------+------+-------+------------------+-----------+---------------+
| Id | User | Host      | db | Command | Time | State | Info             | Rows_sent | Rows_examined |
+----+------+-----------+----+---------+------+-------+------------------+-----------+---------------+
| 13 | root | localhost |    | Query   | 0    | init  | show processlist | 0         | 0             |
+----+------+-----------+----+---------+------+-------+------------------+-----------+---------------+
7、通过mysqladmin创建数据库
[root@rh64 ~]# mysqladmin -u root -p create  testdb;

Enter password: 

删除数据库:

[root@rh64 ~]# mysqladmin -u root -p drop testdb;
Enter password: 
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 'testdb' database [y/N] y
Database "testdb" dropped
8、mysql server重新载入权限列表
[root@rh64 ~]# mysqladmin -u root -p reload

Enter password: 
[root@rh64 ~]# mysqladmin -u root -p refresh
Enter password: 
[root@rh64 ~]# mysqladmin -u root -p flush-hosts
Enter password: 
[root@rh64 ~]# mysqladmin -u root -p flush-logs
Enter password: 
[root@rh64 ~]# mysqladmin -u root -p flush-privileges
Enter password: 
[root@rh64 ~]# mysqladmin -u root -p flush-status
Enter password: 
[root@rh64 ~]# mysqladmin -u root -p flush-tables
Enter password: 
[root@rh64 ~]# mysqladmin -u root -p flush-threads
Enter password: 
9、通过mysqladmin关库
[root@rh64 ~]# mysqladmin -u root -p shutdown 

Enter password: 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值