System Status
Buy Now
  • Email & Apps
  • Office 365
Login
  • MyRackspace Portal
  • Cloud Control Panel
  • Rackspace Webmail Login
  • Cloud Office Control Panel
  • Support Home
  • How-To
  • Developer Documentation
  •  Blogs 
    • Expert Insights Tech Blog
    • Rackspace Blog
    • Solve: Thought Leadership

Support Network

End-to-End Multicloud Solutions.   Solving Together.â„¢   Learn more at Rackspace.com

How–To Home

Cloud Servers

  • Introduction
  • FAQ
  • All Articles

Change the MySQL timeout on a server

Last updated on:  2020-07-13

Authored by:  Rose Contreras


When an application fails to close an unused connection, a low wait_timeout value helps you avoid exceeding the permitted number of connections. Use the following instructions to set this vakue:

  1. Log in to your server by using Secure Shell® (SSH).

  2. Use the sudo command to edit my.cnf, the MySQL® configuration file.

     $ sudo vi /etc/my.cnf
    
  3. Locate the timeout configuration and make the adjustments that fit your server.

     wait_timeout = 28800
     interactive_timeout = 28800
    
    • The interactive_timeout value does not affect any web application connections. A low wait_timeout is a normal best practice.

    • Stateless PHP environments do well with a 60-second timeout or less. Applications that use a connection pool (Java®, .NET®, and so on) need to adjust the wait_timeout value to match their connection pool settings. The default 8 hours = 28800 seconds works well with properly-configured connection pools.

    • Configure the wait_timeout to be slightly longer than the application connection pool’s expected connection lifetime as a safety check. Consider changing the value online because that does not require a MySQL restart, and you can adjusted it while the server runs without incurring downtime. Change the value to set global wait_timeout=60, and any newly created sessions inherit it. Be sure to preserve the setting in my.cnf. Any existing connections need to hit the old value of wait_timeout if the application abandoned the connection. If you do have reporting jobs that do longer local processing while in a transaction, you might consider having such jobs issue set session wait_timeout=3600 upon connecting.

  4. Save the changes and exit the editor.

  5. Use the following command to restart MySQL and apply the changes, if required:

     $ sudo /etc/init.d/mysql restart
    

Share this information:

©2020 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

See license specifics and DISCLAIMER

About Rackspace
  • About
  • Customer Stories
  • Events
  • Programs
Blogs
  • The Rackspace Blog
  • Expert Insights Tech Blog
  • Solve: Thought Leadership
  • News
  • Contact Information
  • Legal
  • Careers
Site Information
  • Style Guide for Technical Content
  • Trademarks
  • Privacy Statement
  • Website Terms
Support Network
  • Support Network Home
  • Rackspace How-To
  • API Documentation
  • Developer Center
  • ©2020 Rackspace US, Inc.