Show the default value for a variable

c# default value for property
c# default value parameter
c# struct default values
c# get default value of type
c# property default value if null
c# default(object)
c# array default value
default value c# method

I am using SET GLOBAL <variable> = <value> to modify dynamic settings in mysql and I am wondering if there is some way to get the default value for each variable? For instance, if I use the following:

SET GLOBAL max_connections = 1000;

and then list the variable using:


I can see the modified value 1000, but is there possible to get the default value for this system variable without checking the configuration files?

I am using mysql 5.7 on ubuntu 16.04.

From the manual:

To set a global system variable value to the compiled-in MySQL default value [...] set the variable to the value DEFAULT.

That means you can do this:

SET @@GLOBAL.max_connections = 1234;

 * Proceed in this order
 * 1) Backup current value
 * 2) Reset to default
 * 3) Read the current value
 * 4) Restore the backup value if necesssary

SET @oldvalue = @@GLOBAL.max_connections;
SET @@GLOBAL.max_connections = DEFAULT;
SET @defvalue = @@GLOBAL.max_connections;
SET @@GLOBAL.max_connections = @oldvalue;

SELECT @@GLOBAL.max_connections AS `current value`
     , @defvalue AS `default value`
-- 1234 and 151

The @oldvalue and @defvalue are user variables.

Default values of C# types, The following table shows the default values of C# types: you can use the default literal to initialize a variable with the default value of its type:. Default value of variable in java Variables declared inside a class are known as member variables (static or non static). These variables are initialized with their default value depending on the type of variable. For example variable of type int contains 0 by default, double variable contains 0.0, etc.

In MySQL 5.7 you can use performance_schema to get the variables.

Before modifying or set you can select the variable to see the default value then modify.

Method #1

    VARIABLE_NAME = 'max_connections';

Output #1

| :------------- |
| 151            |

Method #2

If you are not sure the exact name of variable use like, it can used used also in above query too.


Output #2

Variable_name      | Value
:----------------- | :----
max_connect_errors | 100  
max_connections    | 151  

Method #3

SELECT @@GLOBAL.max_connections;

Output #3

| @@GLOBAL.max_connections |
| -----------------------: |
|                      151 |

Refer here db-fiddle

Note: If you need to have a history kind of thing then you need to create a table to store those values before changing.

P.S. There is one more type of variables session. By replacing global to session those variables can be changed but it will affect only to the current session.

credits: @scaisedge, @richard

default value expressions, Use the default value expressions to obtain the default value of a type. the default operator must be the name of a type or a type parameter, as the following example shows: In the assignment or initialization of a variable. You will not be able to set a default value using a Picklist Choice set. Reason being, the value of the variable gets calculated at run time. The only way you will be able to set the default value would be to create individual choice for each picklist value and then set one of them as the default value.

Could be selecting from information_schema.GLOBAL_STATUS

from information_schema.GLOBAL_STATUS 
where VARIABLE_NAME = 'max_connections';

How to set a default value for a variable? - Support, How can I have my variable select a different default value other than the first one​? I see it might be possible according to this thread but I see  Use of an indeterminate value obtained by default-initializing a non-class variable of any type is undefined behavior (in particular, it may be a trap representation), except in the following cases:

This might not be ideal but if it were me trying to solve the problem I'd create my own table with all of the initial values and reference that when I needed.


This would require you to spin up a new DB installation that is the same version as the one you're currently using, but I think you could use this method to solve your problem.

Simply export the data and import it wherever you need it.

I don't currently see any built-in way to query the defaults.

In a List type variable, options still show after choice type is selected , Description. For a List type variable (in the sys-dictionary), when the choice type "​Dropdown without --None-- (must specify a default value)" is  How can I use Windows PowerShell to prompt a user for a value for a variable, but provide a default value if the user doesn’t enter anything? First prompt the user for the value to the variable and then detect if the response was empty. If the response is empty, set the value of the variable.

Have you tried using this

mysqld --verbose --help

based on it will display compiled-in default.

To see specific variable you may use grep:

mysqld --verbose --help | grep -i 'max-connections'

Variable initialization and default values – ajduke's blog, and when you try to access the variable you get the default value of that variable. Following table shows variables types and their default values  In a blueprint, you can access default values for variables by calling 'Get Class Defaults'

How to order and set the default value in a combo box, In the example below, it should assign the 'User.Id' to the local variable 'UserId'. image alt text. The example below shows the combo box displaying the sorted  Default values. PL/SQL allows you to set a default value for a variable at the declaration time. To assign a default value to a variable, you use the assignment operator (:=) or the DEFAULT keyword. The following example declares a variable named l_product_name with an initial value 'Laptop':

3 Ways to Set Default Value in JavaScript, Let's break down the 3 different ways to set Default Values using logical operator, been the ternary operator for assigning a value to a variable conditionally. Variable a is declared outside of all functions. Hence, a is in global scope. Variable b is declared inside a function baz(). Hence, b is in function scope, ie the scope of baz(). The variable b can be used only inside the function baz(). Default value. Default value of a variable declared using var is undefined.

HTML DOM Input Text defaultValue Property, The defaultValue property sets or returns the default value of a text field. An example that shows the difference between the defaultValue and value property:. One way I accomplish this is to use the OnHidden propery on the screen I am navigating away from. To reset the value, I am pretty sure it depends on what the variable's type is (text, number, etc.). If you are using text, you can use: Set(idSSTVar, "") If it is a number, this can be a bit tricky, depending on the values. For IDs, I set it to 0.

  • I believe it is 151 for max_connections.…
  • This was just an example and does not answer the question :)
  • I think you have to look at official documentation for the variables, one you have overwritten them with custom values.
  • I know I can check the documentation, the question is if and how I can do this without reading the documentation for each variable :)
  • This seems to be a good solution. I will try this as soon as possible and see if it works as expected.
  • Hm, the table does not contain any variable named max_connections? Looking on the global_variables table it contains the variable, but with the changed value. Any thoughts on how to solve this?
  • I am runng mysql 5.7
  • Did you have any more ideas on how to solve this?
  • the default value is 151 as in doc…
  • Yes I know I can check the documentation to get this information, but you don't have any thoughts on how to do this by actually querying the database?
  • This is a good idea to keep track of the default values, but in this case I don't really have any possibility to create any tables since I don't have write access to the database.