mysql中使用show variables同時查詢多個參數值?show variables的使用?

來源:互聯網
上載者:User

標籤:exp   out   ati   row   表示   語句   時間   HERE   --   

需求描述:

  今天在查mysq關於串連數的問題,想要通過一個show variables命令同時查出來多個值.在此記錄下.

操作過程:

1.通過show variables語句的like可以匹配多個值或者某個值

mysql> show variables like ‘max_connections‘;   #這裡預設的就是對Variable_name進行匹配,這裡是準確匹配.+-----------------+-------+| Variable_name   | Value |+-----------------+-------+| max_connections | 151   |+-----------------+-------+1 row in set (0.01 sec)mysql> show variables like ‘socket‘;+---------------+-----------------+| Variable_name | Value           |+---------------+-----------------+| socket        | /tmp/mysql.sock |+---------------+-----------------+1 row in set (0.00 sec)

2.通過%萬用字元進行匹配

mysql> show variables like ‘%connec%‘;      #通過百分比符號(%)這個萬用字元進行匹配,可以匹配多項.+-----------------------------------------------+-------------------+| Variable_name                                 | Value             |+-----------------------------------------------+-------------------+| character_set_connection                      | latin1            || collation_connection                          | latin1_swedish_ci || connect_timeout                               | 10                || disconnect_on_expired_password                | ON                || init_connect                                  |                   || max_connect_errors                            | 100               || max_connections                               | 151               || max_user_connections                          | 0                 || performance_schema_session_connect_attrs_size | 512               |+-----------------------------------------------+-------------------+9 rows in set (0.00 sec)

mysql> show variables like ‘innodb_thread%‘; #%萬用字元在結束處.
+---------------------------+-------+
| Variable_name             | Value |
+---------------------------+-------+
| innodb_thread_concurrency | 0     |
| innodb_thread_sleep_delay | 10000 |
+---------------------------+-------+
2 rows in set (0.00 sec)

mysql> show variables like ‘%version‘; #%萬用字元在開始處.
+------------------+---------------+
| Variable_name    | Value         |
+------------------+---------------+
| innodb_version   | 5.7.21        |
| protocol_version | 10            |
| tls_version      | TLSv1,TLSv1.1 |
| version          | 5.7.21-log    |
+------------------+---------------+
4 rows in set (0.00 sec)

3.使用where子句進行匹配查詢

mysql> show variables where variable_name = ‘version‘;+---------------+------------+| Variable_name | Value      |+---------------+------------+| version       | 5.7.21-log |+---------------+------------+1 row in set (0.01 sec)mysql> show variables where variable_name in (‘version‘,‘innodb_version‘);+----------------+------------+| Variable_name  | Value      |+----------------+------------+| innodb_version | 5.7.21     || version        | 5.7.21-log |+----------------+------------+2 rows in set (0.00 sec)mysql> show variables where value like ‘5.7%‘;+----------------+------------+| Variable_name  | Value      |+----------------+------------+| innodb_version | 5.7.21     || version        | 5.7.21-log |+----------------+------------+2 rows in set (0.00 sec)mysql> show variables where variable_name = ‘version‘ and value = ‘5.7‘;Empty set (0.00 sec)mysql> show variables where variable_name = ‘version‘ and value like ‘5.7%‘;+---------------+------------+| Variable_name | Value      |+---------------+------------+| version       | 5.7.21-log |+---------------+------------+1 row in set (0.00 sec)

備忘:使用where子句的方式就和在SQL語句中使用where的方式是一樣的.

 

小結:

  • show variables主要是用來查看系統變數的值.
  • 執行SHOW VARIABLES命令不需要任何許可權,只要求能夠串連到伺服器就可以.
  • 使用like語句表示用variable_name進行匹配.

 

文檔建立時間:2018年7月17日11:33:27

mysql中使用show variables同時查詢多個參數值?show variables的使用?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.