0

In MySQL there are two values for some parameters:

1) For session.
2) For global.

We can check the values for such parameters like:

1) show variables like 'wait_timeout'
2) show global variables like 'wait_timeout'

Now it returns the values:
1) for session = 500
2) For global = 28800

I am able to change the variables by command:
set global wait_timeout=100 ;
set session wait_timeout= 200;

But when i logged in again i am getting the following values:
for session = 500
for global = 100.

It means global values retain and session not, which is absolutely correct. But my concern is how we can change the session variables then for all sessions ? Because global is not that values taken by each session in this case.

1
  • in docs, i read that each session gets the value from global variables but why it shows different, any idea ? Commented Jul 7, 2016 at 6:59

2 Answers 2

1

Yes,

there a 2 timeouts in MySQL. which one is take for your connection depends on the connections type. one is for the BATCH processing and the other for interactive

the second variable is the interactive_timeout.

look at the setting of interactive_timeout

SHOW VARIABLES LIKE 'interactive_timeout';
SHOW GLOBAL VARIABLES LIKE 'interactive_timeout';

sample login via mysql client

# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 106426
Server version: 10.1.10-MariaDB-log Homebrew

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 500   |
+---------------+-------+
1 row in set (0.00 sec)

MariaDB [(none)]> show global variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 28800 |
+---------------+-------+
1 row in set (0.00 sec)

MariaDB [(none)]> show variables like 'interactive_timeout';
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| interactive_timeout | 500   |
+---------------------+-------+
1 row in set (0.01 sec)

MariaDB [(none)]> show global variables like 'interactive_timeout';
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| interactive_timeout | 500   |
+---------------------+-------+
1 row in set (0.00 sec)

MariaDB [(none)]>

now the same in batch mode

# mysql -uroot -p -e "show variables like 'wait_timeout';"
Enter password:
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 28800 |
+---------------+-------+
#
Sign up to request clarification or add additional context in comments.

5 Comments

So you mean, when we are connecting via shell, it will take the wait_timeout value same as interactive_timeout ?
normal yes, but it is only a parameter in the connection and i can say how your tools connect. verify the settings in the /etc/mysql/my.cnf and test the setting or set bot values to the same in the my.cnf
i am conecting via normal mysql client in interactive mode in linux.
@Aman Aggarwal - i have add a sample in my answer there you can see the difference
i got your point.. So it means interactive timeout becomes wait timeout..
0

I got the exact description:

On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect())

In MySQL doc wait_timeout description

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.