Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql.connect_timeout in php vs connect_timeout in mysql

What is the difference between :

mysql.connect_timeout   

that we can find in php.ini

and

connect_timeout

that belongs to mysql configuration (show variables).

Knowing that apache server and mysql server are two distant VPS with a VIP between them, what is the value considered by the whole environment (Varnish + Apache + Mysql) ?

like image 563
4m1nh4j1 Avatar asked Aug 19 '14 08:08

4m1nh4j1


People also ask

What is the default Wait_timeout in MySQL?

MySQL has its wait_timeout variable default value set to 28800 seconds (8 hours).

Could not run MySQL server has gone away?

The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection. In this case, you normally get one of the following error codes (which one you get is operating system-dependent). The client couldn't send a question to the server.


1 Answers

mysql.connect_timeout tells PHP how long it should wait for a response from the MySQL server when it tries to connect.

connect_timeout in MySQL configuration tells the MySQL server how long to wait for a connect packet from the client before responding with a Bad handshake error.

Apache is not involved in either of these timeouts, they're just between PHP and MySQL. First PHP connects to MySQL; if it doesn't get a response before mysql.connect_timeout, it will report an error. Once that succeeds, PHP sends a connect packet to MySQL; if it doesn't do that within connect_timeout, MySQL will report an error and close the connection.

like image 120
Barmar Avatar answered Oct 04 '22 23:10

Barmar