mysql command for showing current configuration variables
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
MySQL exposes its runtime configuration through server variables, and the fastest way to inspect them is from SQL. This is essential for troubleshooting, performance tuning, and checking whether a configuration file change actually took effect. The main commands are SHOW VARIABLES, SHOW GLOBAL VARIABLES, and direct reads through the @@ syntax.
Show All Current Variables
To list the current server variables and their values:
That returns both session and global variables as seen by the current connection. On a real server, the output is long, so most of the time you will filter it.
For global scope only:
For session scope only:
This distinction matters because some variables can differ per connection while others are server-wide.
Filter with LIKE
In practice, you usually want one variable or one family of variables.
This is the quickest day-to-day admin pattern because it avoids scrolling through hundreds of lines.
Read One Variable Directly
If you already know the variable name, the @@ syntax is compact and script-friendly.
This is especially useful in monitoring scripts or one-off checks where you want a single scalar value instead of a two-column result set.
Understand Global Versus Session
A common source of confusion is that some variables exist in both global and session scope.
For example:
The global value is the server default for new connections. The session value is what your current connection is using right now. If a client or application changes a session variable after connecting, the two can differ.
That is why checking only one scope can lead to false conclusions during debugging.
See What Can Be Changed at Runtime
Many MySQL variables are dynamic, which means they can be changed without restarting the server.
Example:
Others are static and only change after editing the config file and restarting MySQL. When a value is unexpected, verify both:
- what the config file says
- what the running server currently exposes
The runtime value is what actually matters for live behavior.
Use Information Schema or Performance Schema When Needed
Modern MySQL also exposes variable metadata through schema tables, which can be helpful for tooling.
This is less convenient for ad hoc interactive use than SHOW VARIABLES, but it is useful when you want queryable metadata from SQL tables.
Typical Admin Checks
A few common variables worth checking during investigation:
- '
max_connectionsfor connection saturation' - '
innodb_buffer_pool_sizefor InnoDB memory tuning' - '
sql_modefor behavioral differences between environments' - '
character_set_serverandcollation_serverfor encoding issues' - '
slow_query_logandlong_query_timefor performance diagnostics'
Example:
These quick checks are often enough to explain why one environment behaves differently from another.
Common Pitfalls
- Checking session scope when the real question was about global scope.
- Assuming a config file change is active without verifying the running value.
- Searching manually through
SHOW VARIABLESinstead of filtering withLIKE. - Forgetting that applications may override session variables after connecting.
- Changing a global variable at runtime and assuming it will persist after restart.
Summary
- '
SHOW VARIABLESis the standard MySQL command for viewing current configuration values.' - Use
SHOW GLOBAL VARIABLESorSHOW SESSION VARIABLESwhen scope matters. - Use
LIKEto filter by variable name or prefix. - Use
@@GLOBAL.var_nameand@@SESSION.var_namefor direct one-value reads. - Always verify the runtime value, not just the config file, when troubleshooting MySQL behavior.

