欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

MySQL mysqladmin客戶端的使用簡介

 更新時間:2021年03月27日 14:58:16   作者:AsiaYe  
這篇文章主要介紹了MySQL mysqladmin客戶端的使用簡介,幫助大家更好的理解和學(xué)習(xí)使用MySQL,感興趣的朋友可以了解下

     mysqladmin是MySQL官方提供的shell命令行工具,它的參數(shù)都需要在shell命令行里面執(zhí)行,當(dāng)我們使用mysqladmin的時候,必須指定兩類參數(shù),一類是連接參數(shù),另外一類是命令參數(shù),連接參數(shù)用來指定相應(yīng)的連接信息,而命令參數(shù)用來指定命令信息,例如可以用來檢查服務(wù)器的配置和當(dāng)前狀態(tài)、創(chuàng)建和刪除數(shù)據(jù)庫等。它的語法如下:

mysqladmin [options] command [command-options] [command [command options]] ...

除此之外,還有一些相關(guān)的參數(shù)配置(代碼可以左滑哦~):

--bind-address=name 綁定遠(yuǎn)程訪問主機(jī)的ip地址
-i, --sleep=#   間隔多長時間執(zhí)行一次。
-c, --count=#   統(tǒng)計計數(shù)。與i選項配合使用。
-f, --force   強(qiáng)制執(zhí)行,刪除數(shù)據(jù)庫是無需確認(rèn)信息,多條語句執(zhí)行時忽略其中某條語句的錯誤。
--default-character-set=name 設(shè)置默認(rèn)字符集。
-?, --help    顯示幫助信息。
-h, --host=name  指定連接主機(jī)。
-u, --user=name  登錄用戶。
-p, --password[=name] 登錄密碼,如果不寫于參數(shù)后,則會提示輸入。
-P, --port=#   指定數(shù)據(jù)庫端口。
--protocol=name  使用的連接協(xié)議。(tcp,socket,pipe,memory)
-r, --relative   顯示前后兩次輸出的差異。必須與i選項配合使用。
-s, --silent   靜默退出。
-S, --socket=name  指定socket文件。
-v, --verbose   顯示更多信息。
-V, --version   顯示版本信息。
-w, --wait[=#]   如果連接斷開,等待指定的時間后重試

    這么多參數(shù),想看著比較亂,那么我們來看看它具體能夠幫我們做哪些事情吧:

1.查看服務(wù)器的狀態(tài):

#每隔兩秒查看一次服務(wù)器的狀態(tài)
[root@dev01 ~]# mysqladmin -uroot -p -i 2 -c 2 status
Enter password: 
Uptime: 42767 Threads: 2 Questions: 533 Slow queries: 0 Opens: 346 Flush tables: Open tables: Queries per second avg: 0.012
Uptime: Threads: Questions: Slow queries: Opens: Flush tables: Open tables: Queries per second avg: 0.012

2.修改root密碼:

#修改root密碼
mysqladmin -u root -p原密碼 password 'newpassword'

3.檢查mysqlserver是否可用

#查詢服務(wù)是否正常
[root@dev01 ~]# mysqladmin -uroot -p ping
Enter password: 
mysqld is alive

4.查詢服務(wù)器的版本

[root@dev01 ~]# mysqladmin -uroot -p version
Enter password: 
mysqladmin Ver 8.42 Distrib 5.7.19, for linux-glibc2.12 on x86_64
Copyright (c) 2000, 2017, 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.19
Protocol version 10
Connection  Localhost via UNIX socket
UNIX socket  /tmp/mysql.sock
Uptime:   12 hours 42 sec

Threads: 2 Questions: 538 Slow queries: 0 Opens: 346 Flush tables: 1 Open tables: 285 Queries per second avg: 0.012

5.查看系統(tǒng)當(dāng)前的狀態(tài)值 (省略其中的部分結(jié)果)

[root@dev01 ~]# mysqladmin -uroot -p extended-status
Enter password: 
+-----------------------------------------------+----------+
| Variable_name         | Value |
+-----------------------------------------------+----------+
| Aborted_clients        |   |
| Aborted_connects        |   |
| Innodb_num_open_files       |  |
| Innodb_truncated_status_writes    |   |            
| Uptime          |  |
| Uptime_since_flush_status      |  |
+-----------------------------------------------+----------+

6.查看服務(wù)器系統(tǒng)變量值

[root@dev01 ~]# mysqladmin -uroot -p variables
Enter password: 
......
| key_cache_block_size    |                                                                                         |
| key_cache_division_limit   |                                                                                             |
| large_files_support    | ON                                                                                                    |
| large_page_size     |                                                                                                     |
| large_pages      | OFF                                                                                                    |
| lc_messages      | en_US                                                                                                   |
| lc_messages_dir     | /usr/local/mysql/share/                                                                                               |
......

7.查看當(dāng)前所有的進(jìn)程

[root@dev01 ~]# mysqladmin -uroot -p processlist
Enter password: 
+----+------+----------------------+----------+---------+-------+----------+------------------+
| Id | User | Host     | db  | Command | Time | State | Info    |
+----+------+----------------------+----------+---------+-------+----------+------------------+
| | root | 192.168.56.102: | devopsdb | Sleep | |   |     |
| | root | localhost   |   | Query |  | starting | show processlist |
+----+------+----------------------+----------+---------+-------+----------+------------------+

8.創(chuàng)建數(shù)據(jù)庫

[root@dev01 ~]# mysqladmin -uroot -p create db_test
Enter password: 
[root@dev01 ~]# mysql -uroot -p
Enter password: 
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database   |
+--------------------+
| information_schema |
| TkGrowDB_dbo  |
| TkGrowLog_dbo  |
| cydevopsdb   |
| db_test   |
| yeyz    |
+--------------------+
 rows in set (0.00 sec)

mysql> exit
Bye

從上面的命令我們可以看到,我們已經(jīng)通過create命令創(chuàng)建了數(shù)據(jù)庫db_test

9.刪除特定的數(shù)據(jù)庫:

[root@dev01 ~]# mysqladmin -uroot -p drop db_test
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 'db_test' database [y/N] y
Database "db_test" dropped
[root@dev01 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database   |
+--------------------+
| information_schema |
| TkGrowDB_dbo  |
| TkGrowLog_dbo  |
| cydevopsdb   |
| yeyz    |
+--------------------+
 rows in set (0.00 sec)

    在我們?nèi)粘2僮髦?,drop操作應(yīng)該謹(jǐn)慎一些,可以看到,mysql也友好的給出了提醒。

10.重載權(quán)限表和刷新緩存(無明顯輸出)

[root@dev01 ~]# mysqladmin -uroot -p reload
Enter password:
[root@dev01 ~]# mysqladmin -uroot -p refresh
Enter password:

11.啟用安全模式關(guān)閉數(shù)據(jù)庫

[root@dev01 ~]# ps -ef|grep mysqld
root    : ?  :: /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/dev01.pid
mysql   : ?  :: /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/mysqld.log --pid-file=/data/mysql/dev01.pid --socket=/tmp/mysql.sock
root   : pts/ :: grep mysqld
[root@dev01 ~]# mysqladmin -uroot -p shutdown
Enter password: 
[root@dev01 ~]# ps -ef|grep mysqld
root   : pts/ :: grep mysqld

12.各種刷新命令

[root@dev01 ~]# mysqladmin -u root -ptmppassword flush-hosts
[root@dev01 ~]# mysqladmin -u root -ptmppassword flush-logs
[root@dev01 ~]# mysqladmin -u root -ptmppassword flush-privileges
[root@dev01 ~]# mysqladmin -u root -ptmppassword flush-status
[root@dev01 ~]# mysqladmin -u root -ptmppassword flush-tables
[root@dev01 ~]# mysqladmin -u root -ptmppassword flush-threads

13.停止和啟動MySQL從節(jié)點復(fù)制過程

[root@dev01 ~]# mysqladmin -u root -p stop-slave
[root@dev01 ~]# mysqladmin -u root -p start-slave

以上就是mysqladmin最常用的一些功能,標(biāo)注為紅色的一般在工作中應(yīng)用的范圍及其廣泛,可以多留意下。

以上就是MySQL mysqladmin客戶端的使用簡介的詳細(xì)內(nèi)容,更多關(guān)于MySQL mysqladmin客戶端的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Mysql誤刪除DELETE數(shù)據(jù)找回操作指南

    Mysql誤刪除DELETE數(shù)據(jù)找回操作指南

    如果我們在數(shù)據(jù)庫中不小心執(zhí)行了類似"delete from t1"這樣的不帶where條件的語句,那么整張表的數(shù)據(jù)就全被刪除了,下面這篇文章主要給大家介紹了關(guān)于Mysql誤刪除DELETE數(shù)據(jù)找回操作的相關(guān)資料,需要的朋友可以參考下
    2023-05-05
  • MySQL的Flush-List和臟頁的落盤機(jī)制

    MySQL的Flush-List和臟頁的落盤機(jī)制

    這篇文章主要介紹了MySQL的Flush-List和臟頁的落盤機(jī)制,幫助大家更好的理解和使用MySQL,感興趣的朋友可以了解下
    2020-11-11
  • 淺談MySQL中的六種日志

    淺談MySQL中的六種日志

    MySQL中存在著6種日志,本文是對MySQL日志文件的概念及基本使用介紹,不涉及底層內(nèi)容,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • percona 實用工具之pt-kill使用介紹

    percona 實用工具之pt-kill使用介紹

    一個優(yōu)秀的kill MySQL連接的一個工具,是percona toolkit的一部分,在因為空閑連接較多導(dǎo)致超過最大連接數(shù)、某個有問題的sql導(dǎo)致mysql負(fù)載很高時,都需要將一些連接kill掉,這個工具主要就是這個用途
    2016-04-04
  • MySQL中的批量修改、插入操作數(shù)據(jù)庫

    MySQL中的批量修改、插入操作數(shù)據(jù)庫

    在平常的項目中,我們會需要批量操作數(shù)據(jù)庫的時候,例如:批量修改,批量插入,那我們不應(yīng)該使用 for 循環(huán)去操作數(shù)據(jù)庫,這樣會導(dǎo)致我們反復(fù)與數(shù)據(jù)庫發(fā)生連接和斷開連接,影響性能和增加操作時間,所以可以使用SQL 批量修改的方式去操作數(shù)據(jù)庫,感興趣的朋友一起學(xué)習(xí)下吧
    2023-09-09
  • 數(shù)據(jù)庫中的SELECT語句邏輯執(zhí)行順序分析

    數(shù)據(jù)庫中的SELECT語句邏輯執(zhí)行順序分析

    這篇文章主要介紹了數(shù)據(jù)庫中的SELECT語句邏輯執(zhí)行順序分析,并列出了一些例子,需要的朋友可以參考下
    2014-07-07
  • MySQL DML語句整理匯總

    MySQL DML語句整理匯總

    這篇文章主要介紹了MySQL DML語句整理匯總,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • MySQL權(quán)限USAGE和ALL PRIVILEGES的用法

    MySQL權(quán)限USAGE和ALL PRIVILEGES的用法

    本文主要介紹了MySQL權(quán)限USAGE和ALL PRIVILEGES的用法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2024-09-09
  • MySQL占用CPU過高排查過程及可能優(yōu)化方案

    MySQL占用CPU過高排查過程及可能優(yōu)化方案

    這篇文章主要介紹了MySQL占用CPU過高排查過程及可能優(yōu)化方案,具有很好的參考價值,希望對大家的學(xué)習(xí)或工作有所幫助,感興趣的朋友可以參考下
    2024-01-01
  • 一文教你如何使用MySQL觸發(fā)器

    一文教你如何使用MySQL觸發(fā)器

    觸發(fā)器(TRIGGER)是MySQL的數(shù)據(jù)庫對象之一,是一種特殊類型的存儲過程,從5.0版本開始支持,下面這篇文章主要給大家介紹了關(guān)于如何使用MySQL觸發(fā)器的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-05-05

最新評論