mysql command for showing current configuration variables

后端 未结 3 1309
野性不改
野性不改 2021-01-29 23:36

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

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

3条回答
  •  攒了一身酷
    2021-01-30 00:30

    As an alternative you can also query the information_schema database and retrieve the data from the global_variables (and global_status of 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.

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

    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)
    

提交回复
热议问题