Reprinted from: http://www.cnblogs.com/symen/p/6112474.html
Add two values of wait_timeout and interactive_timeout to the mysql configuration file
[mysqld] wait_timeout=315360000 interactive_timeout=315360000
Timeout period, 10 years
Restart mysql: service mysqld restart
login mysql
show variables like '%timeout%';
+-----------------------------+----------+
| Variable_name | Value |
+-----------------------------+----------+
| interactive_timeout | 31536000 |
| wait_timeout | 31536000 |
+-----------------------------+----------+
13 rows in set (0.00 sec)
Seeing that the value has changed, the setting is successful