用于显示当前配置变量的 mysql 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1493722/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:11:37  来源:igfitidea点击:

mysql command for showing current configuration variables

mysqlmysql-management

提问by Brian G

Can not find a command that displays the current configuration of mysql from within the database.

无法从数据库中找到显示 mysql 当前配置的命令。

I know I could look at /etc/mysql/my.cnf but that is not what I need.

我知道我可以查看 /etc/mysql/my.cnf 但这不是我需要的。

回答by code_burgar

What you are looking for is this:

你要找的是这个:

SHOW VARIABLES;  

You can modify it further like any query:

您可以像任何查询一样进一步修改它:

SHOW VARIABLES LIKE '%max%';  

回答by Seth

Use SHOW VARIABLES:

使用SHOW VARIABLES

show variables like 'version';

显示变量,如“版本”;

回答by Stefan

As an alternative you can also query the information_schemadatabase and retrieve the data from the global_variables(and global_statusof course too). This approach provides the same information, but gives you the opportunity to do more with the results, as it is a plain old query.

作为替代方案,您还可以查询information_schema数据库并从中检索数据global_variablesglobal_status当然也可以)。这种方法提供相同的信息,但让您有机会对结果做更多​​的事情,因为它是一个普通的旧查询。

For example you can convert units to become more readable. The following query provides the current global setting for the innodb_log_buffer_sizein bytes and megabytes:

例如,您可以转换单位以提高可读性。以下查询提供了innodb_log_buffer_size以字节和兆字节为单位的当前全局设置:

SELECT
  variable_name,
  variable_value AS innodb_log_buffer_size_bytes,
  ROUND(variable_value / (1024*1024)) AS innodb_log_buffer_size_mb
FROM information_schema.global_variables
WHERE variable_name LIKE  'innodb_log_buffer_size';

As a result you get:

结果你得到:

+------------------------+------------------------------+---------------------------+
| variable_name          | innodb_log_buffer_size_bytes | innodb_log_buffer_size_mb |
+------------------------+------------------------------+---------------------------+
| INNODB_LOG_BUFFER_SIZE | 268435456                    |                       256 |
+------------------------+------------------------------+---------------------------+
1 row in set (0,00 sec)