可以通过以下 SQL 语句查询相关配置参数的当前值:
-
InnoDB 缓冲池大小 (
innodb_buffer_pool_size
):sqlSHOW VARIABLES LIKE 'innodb_buffer_pool_size';
-
最大连接数 (
max_connections
):sqlSHOW VARIABLES LIKE 'max_connections';
-
临时表大小 (
tmp_table_size
和max_heap_table_size
):sqlSHOW VARIABLES LIKE 'tmp_table_size'; SHOW VARIABLES LIKE 'max_heap_table_size';
-
查询缓存 (
query_cache_size
和query_cache_type
):sqlSHOW VARIABLES LIKE 'query_cache_size'; SHOW VARIABLES LIKE 'query_cache_type';
-
排序缓冲区和联合缓冲区 (
sort_buffer_size
和join_buffer_size
):sqlSHOW VARIABLES LIKE 'sort_buffer_size'; SHOW VARIABLES LIKE 'join_buffer_size';
-
其他参数 (
read_buffer_size
、read_rnd_buffer_size
和key_buffer_size
):sqlSHOW VARIABLES LIKE 'read_buffer_size'; SHOW VARIABLES LIKE 'read_rnd_buffer_size'; SHOW VARIABLES LIKE 'key_buffer_size';
示例查询结果:
sql
SHOW VARIABLES LIKE 'innodb_buffer_pool_size';
输出示例:查到的结果除以3个1024就可以把单位转换成G
+-------------------------+-----------+
| Variable_name | Value |
+-------------------------+-----------+
| innodb_buffer_pool_size | 134217728 |
+-------------------------+-----------+