MySQL Workbench: How to Keep the Connection Alive
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
MySQL Workbench is a unified visual tool for database architects, developers, and DBAs. It provides data modeling, SQL development, and comprehensive administration tools. This guide focuses on how to keep the connection alive in MySQL Workbench, ensuring uninterrupted work sessions and avoiding the hassle of frequent reconnections.
Connection timeouts in MySQL Workbench occur when the server closes an idle connection after a certain period. This can interrupt workflows and require frequent reconnections, which can be frustrating.
Edit the MySQL Configuration File: Locate and open the my.cnf (Linux) or my.ini (Windows) file in a text editor. This file is typically found in the MySQL installation directory.
[mysqld]
wait_timeout = 28800
interactive_timeout = 28800
wait_timeout: The number of seconds the server waits for activity on a non-interactive connection before closing it.interactive_timeout: Similar to wait_timeout, but for interactive connections like those used by MySQL Workbench.Restart MySQL Service: After editing, restart the MySQL service to apply the changes.
sudo service mysql restart
Open MySQL Workbench Preferences: Launch MySQL Workbench, and navigate to Edit > Preferences (Linux/Windows) or MySQL Workbench > Preferences (macOS).
Configure SQL Editor Settings:
SQL Editor section.DBMS connection keep-alive interval (in seconds).600 for 10 minutes).-- Example of a simple query to keep the connection alive
SELECT 1;
Write a Keep-Alive Script: Create a small SQL script with a simple query (like SELECT 1;) and schedule it to run at regular intervals.
SELECT 1;
If MySQL Workbench settings alone are not sufficient, consider using external tools or scripts that periodically interact with the database to prevent timeouts.
Keeping your MySQL Workbench connection alive is essential for a smooth and uninterrupted workflow. By configuring server and Workbench settings, and optionally using external tools or scripts, you can prevent frequent disconnections due to timeouts. Remember, the key is to balance between server performance and the convenience of a persistent connection.
Written by
Senior Engineer at Basedash
Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.
Basedash lets you build charts, dashboards, and reports in seconds using all your data.