Requirements Description :
I'm checking mysq today. For the connection number problem, you want to detect multiple values simultaneously with a show variables command. In this record.
Operation Process :
1. You can match multiple values or a value by using the like of the show variables statement
Mysql>Show variables like 'max_connections'; #这里默认的就是对Variable_name进行匹配, here is the exact match. +-----------------+-------+|Variable_name|Value|+-----------------+-------+|Max_connections| 151 |+-----------------+-------+1Rowinch Set(0.01sec) MySQL>Show variables like 'Socket';+---------------+-----------------+|Variable_name|Value|+---------------+-----------------+|Socket| /Tmp/Mysql.sock|+---------------+-----------------+1Rowinch Set(0.00Sec
2. Matching with% wildcard characters
Mysql>Show variables like '%connec%'; #通过百分号 (%) match this wildcard character to match multiple items. +-----------------------------------------------+-------------------+|Variable_name|Value|+-----------------------------------------------+-------------------+|Character_set_connection|Latin1||Collation_connection|Latin1_swedish_ci||Connect_timeout| Ten ||Disconnect_on_expired_password| on ||Init_connect| ||Max_connect_errors| - ||Max_connections| 151 ||Max_user_connections| 0 ||Performance_schema_session_connect_attrs_size| + |+-----------------------------------------------+-------------------+9Rowsinch Set(0.00Sec
Mysql> Show variables like ' innodb_thread% ';#% wildcard character at the end.
+---------------------------+-------+
| variable_name | Value |
+---------------------------+-------+
| innodb_thread_concurrency | 0 |
| Innodb_thread_sleep_delay | 10000 |
+---------------------------+-------+
2 rows in Set (0.00 sec)
Mysql> Show variables like '%version ';#% the wildcard character at the beginning.
+------------------+---------------+
| 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. Using the WHERE clause for matching queries
Mysql>Show variableswhereVariable_name= 'version';+---------------+------------+|Variable_name|Value|+---------------+------------+|Version| 5.7. +-Log |+---------------+------------+1Rowinch Set(0.01sec) MySQL>Show variableswhereVariable_nameinch('version','innodb_version');+----------------+------------+|Variable_name|Value|+----------------+------------+|Innodb_version| 5.7. + ||Version| 5.7. +-Log |+----------------+------------+2Rowsinch Set(0.00sec) MySQL>Show variableswhereValue like '5.7%';+----------------+------------+|Variable_name|Value|+----------------+------------+|Innodb_version| 5.7. + ||Version| 5.7. +-Log |+----------------+------------+2Rowsinch Set(0.00sec) MySQL>Show variableswhereVariable_name= 'version' andValue= '5.7'; EmptySet(0.00sec) MySQL>Show variableswhereVariable_name= 'version' andValue like '5.7%';+---------------+------------+|Variable_name|Value|+---------------+------------+|Version| 5.7. +-Log |+---------------+------------+1Rowinch Set(0.00Sec
NOTE: The WHERE clause is used in the same way that you use where in SQL statements.
Summary:
- Show variables is primarily used to view the values of system variables.
- Executing the show variables command does not require any permissions, only the ability to connect to the server is required.
- Use the like statement to indicate a match with variable_name.
Document creation time: July 17, 2018 11:33:27
Using show variables in MySQL to query multiple parameter values at the same time? Use of show variables?