MariaDB—— 4.mysqladmin

mysqladmin 是MySQL官方提供的shell命令行工具(mysql是連接工具),其參數都需要在shell命令行上執行。

1.語法

mysqladmin [options] command1 command2

[root@node2 bin]# mysqladmin 
--character-sets-dir=     extended-status           old-password              --silent                  stop-slave
--compress                flush-hosts               password                  --sleep=                  --tls-version=
--connect-timeout=        flush-logs                --password                --socket=                 --user=
--count=                  flush-privileges          ping                      --ssl                     variables
create                    flush-status              --plugin-dir=             --ssl-ca=                 --verbose
debug                     flush-tables              --port=                   --ssl-capath=             version
--debug-check             flush-threads             --print-defaults          --ssl-cert=               --version
--debug-info              --force                   processlist               --ssl-cipher=             --vertical
--default-auth=           --help                    --protocol=               --ssl-crl=                --wait
--default-character-set=  --host=                   refresh                   --ssl-crlpath=            --wait-for-all-slaves
--defaults-extra-file=    kill                      --relative                --ssl-key=                
--defaults-file=          --local                   reload                    --ssl-verify-server-cert  
--defaults-group-suffix=  --no-beep                 shutdown                  start-slave               
drop                      --no-defaults             --shutdown-timeout=       status            
2.示例
2.1 create/drop databasename
 [root@node2 bin]# mysqladmin  --help | grep database
  -f, --force         Don't ask for confirmation on drop database; with
  create databasename	  Create a new database
  drop databasename	  Delete a database and all its tables
2.2 flush-XX
[root@node2 bin]# mysqladmin  --help | grep flush
  flush-all-statistics    Flush all statistics tables
  flush-all-status        Flush status and statistics
  flush-client-statistics Flush client statistics
  flush-hosts             Flush all cached hosts
  flush-index-statistics  Flush index statistics
  flush-logs              Flush all logs
  flush-privileges        Reload grant tables (same as reload)
  flush-binary-log        Flush binary log
  flush-engine-log        Flush engine log(s)
  flush-error-log         Flush error log
  flush-general-log       Flush general log
  flush-relay-log         Flush relay log
  flush-slow-log          Flush slow query log
  flush-status            Clear status variables
  flush-table-statistics  Clear table statistics
  flush-tables            Flush all tables
  flush-threads           Flush the thread cache
  flush-user-statistics   Flush user statistics
  flush-user-resources    Flush user resources
[root@node2 bin]# mysqladmin  --help | grep reload
  flush-privileges        Reload grant tables (same as reload)
  reload		Reload grant tables
[root@node2 bin]# mysqladmin  --help | grep fresh
  refresh		Flush all tables and close and open logfiles
2.3 連接管理(processlist,kill)、
[root@node2 bin]# mysqladmin processlist 
+----+------+-----------+----+---------+------+-------+------------------+----------+
| Id | User | Host      | db | Command | Time | State | Info             | Progress |
+----+------+-----------+----+---------+------+-------+------------------+----------+
| 21 | root | localhost |    | Query   | 0    | Init  | show processlist | 0.000    |
+----+------+-----------+----+---------+------+-------+------------------+----------+
2.4集羣方面管理(start-slave、stop-slave)
[root@node2 bin]# mysqladmin --help | grep slave
  --wait-for-all-slaves 
                      been sent to all connected slaves
wait-for-all-slaves               FALSE
  start-slave		Start slave
  stop-slave		Stop slave
2.5 其他(status ,etxtended-status , password ,version)
[root@node2 bin]# mysqladmin  password 
New password: 
Confirm new password: 
[root@node2 bin]# mysqladmin  extended-status 
+--------------------------------------------------------------+--------------------------------------------------+
| Variable_name                                                | Value                                            |
+--------------------------------------------------------------+--------------------------------------------------+
| Aborted_clients                                              | 0                                                |
| Aborted_connects                                             | 0                                                |
.................
[root@node2 bin]# mysqladmin  status
Uptime: 75156  Threads: 2  Questions: 22  Slow queries: 0  Opens: 16  Open tables: 10  Queries per second avg: 0.000
[root@node2 bin]# mysqladmin  version
mysqladmin  Ver 9.1 Distrib 10.5.2-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Server version		10.5.2-MariaDB
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/share/mariadb/mariadb10.5/etc/mysql.sock
Uptime:			20 hours 52 min 45 sec

Threads: 2  Questions: 24  Slow queries: 0  Opens: 16  Open tables: 10  Queries per second avg: 0.000
[root@node2 bin]# mysqladmin  extended-status | grep max
| Connection_errors_max_connections                            | 0                                                |
| Innodb_checkpoint_max_age                                    | 80827823                                         |
| Innodb_max_trx_id                                            | 22                                               |
| Innodb_row_lock_time_max                                     | 0                                                |
| Tc_log_max_pages_used                                        | 0                                                |

————Blueicex 2020/2/28 18:51 [email protected]

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章