Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save edmondscommerce/b8c39df2ff000afd72dff156eccdacd5 to your computer and use it in GitHub Desktop.
Save edmondscommerce/b8c39df2ff000afd72dff156eccdacd5 to your computer and use it in GitHub Desktop.
BASH function to get the config value for a variable from MySQL
function getCurrentMysqlConfigForVariable(){
local variable=$1
mysql -e "select variable_value from information_schema.global_variables where variable_name like '$variable'" |
while read variable_value;
do
if [[ 'variable_value' == "$variable_value" ]]
then
# skip the header
continue
fi
echo $variable_value
return 0
done
return 1
}
@edmondscommerce
Copy link
Author

Usage:

user@server getCurrentMysqlConfigForVariable default_storage_engine
InnoDB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment