wait_timeout Mysql | max_connections Mysql
Posted by Raj
wait_timeout Mysql :
wait_timeout defines the number of seconds a mysql thread waits in idle state before mysql kills it.MySQL uses a lot of different timeout variables at different stages.when connection is just being established connect_timeout is used. When server waits for another query to be sent to it wait_timeout.
By default, the server closes the connection after eight hours if nothing has happened.
You can change the time limit by setting the wait_timeout variable when you
start mysqld.
How to find default wait_timeout value?
Use below Query:
mysql> show variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 28800 |
+---------------+-------+
1 row in set (0.00 sec)
=>Default: 28800 seconds.
The most common reason for the MySQL server has gone away error is that the
server timed out and closed the connection.
Errors:
1.MySQL: "Warning: MySQL server has gone away"
2.Mysql error:Too many connections error:
For handling Mysql:Too many connections error:Do not use mysql_pconnect for connecting with the mysql database. you can use mysql_connect.You need to change the time limit by setting the wait_timeout variable when you start mysqld.
Steps:
1.Edit the my.cnf and try to change the following setting:
2.max_connections=200
wait_timeout=60
3.save it.
4.Restart Mysql server.
5. Cheeck below command
mysql> show variables like 'wait_timeout';
4.Done.
OR
Run below command in mysql prompt
mysql> set global wait_timeout = 30
Instead of use wait_timeout, you can set interactive_timeout to short period of time (for ex. 18 sec.)
this is a lot better solution in apache + mysql environment than wait_timeout
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
max_connections,
mysql,
PHP,
PHP interview questions and answers,
set global wait_timeout,
wait_timeout
.You can leave a response, or trackback from your own site.