mysql command for showing current configuration variables

MysqlMysql Management

Mysql Problem Overview


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.

Mysql Solutions


Solution 1 - Mysql

What you are looking for is this:

SHOW VARIABLES;  

You can modify it further like any query:

SHOW VARIABLES LIKE '%max%';  

Solution 2 - Mysql

Use SHOW VARIABLES:

http://dev.mysql.com/doc/refman/5.1/en/show-variables.html">show variables like 'version';

Solution 3 - Mysql

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)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBrian GView Question on Stackoverflow
Solution 1 - Mysqlcode_burgarView Answer on Stackoverflow
Solution 2 - MysqlSethView Answer on Stackoverflow
Solution 3 - MysqlStefanView Answer on Stackoverflow