Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i mysql wait_timeout to unlimited

Tags:

mysql

I have this config

mysql> SHOW VARIABLES where Variable_name like '%timeout';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| connect_timeout            | 5     | 
| delayed_insert_timeout     | 300   | 
| innodb_lock_wait_timeout   | 50    | 
| innodb_rollback_on_timeout | OFF   | 
| interactive_timeout        | 28800 | 
| net_read_timeout           | 30    | 
| net_write_timeout          | 60    | 
| slave_net_timeout          | 7200  | 
| table_lock_wait_timeout    | 50    | 
| wait_timeout               | 28800 | 
+----------------------------+-------+
10 rows in set (0.01 sec)

mysql>

I needs long time connect, want to unlimited timeout.

Look my php source.

<?php
$link = @mysql_connect("localhost","root",$pw);
...
mysql_query($query,$link);
...
// A long time flows (maybe 28,800sec)
mysql_query($query,$link); // error !!
?>

Please advise.

like image 275
jay Avatar asked Sep 08 '15 06:09

jay


2 Answers

The answer is NO. You can not set the wait_timeout to unlimited.

You can refer MYSQL wait_timeout

However if you want to change it then you can try like this:

SET GLOBAL connect_timeout=....;
like image 144
Rahul Tripathi Avatar answered Nov 10 '22 12:11

Rahul Tripathi


There is a limit for wait_timeout. This configuartion value can put in the configuration file my.cnf (for unix)/ my.ini (for windows).

Type    Integer
Default Value           28800;
Minimum Value           1;
Maximum Value (Other)   31536000;
Maximum Value (Windows) 2147483

Assign wait_timeout in the configuration file within the above range and restart the mysql server.

like image 39
blueDexter Avatar answered Nov 10 '22 11:11

blueDexter