Adjust the Timeout Global Variables in Your MySQL Database Server
- Adjusting timeout-related global variables in your MySQL database server typically involves using SQL commands to modify the variables directly.
- Here’s a step-by-step guide to practically adjust these variables:
Step 1: Connect to Your MariaDB Server
Step 2: Open the MySQL Command-Line Client
- If we are using the MySQL command-line client, open our terminal or command prompt and type the following command:
mysql -u your_username -p
- Replace your_username with your actual MySQL username. Press Enter and then enter your password when prompted.
Step 3: Execute SQL Command to Adjust Timeout Variables
- Once connected to the MySQL server, you can execute SQL commands to adjust the timeout-related variables.
- The key variables we may want to adjust include connect_timeout, wait_timeout, and interactive_timeout.
- For example, to set the connect_timeout to 1800 seconds (20 minutes), you can execute the following SQL command:
SET GLOBAL connect_timeout = 1800;
- Similarly, we can adjust other timeout variables as needed. For instance, to set both wait_timeout and interactive_timeout to 600 seconds, we can execute the following SQL commands:
SET GLOBAL wait_timeout = 1800;
SET GLOBAL interactive_timeout = 1800;
Step 4: Verify Changes
- After executing the SQL commands to adjust the timeout variables, we can verify that the changes have taken effect by querying the values of these variables.
- We can do this by executing the following SQL command:
SHOW VARIABLES LIKE 'connect_timeout';
SHOW VARIABLES LIKE 'wait_timeout';
SHOW VARIABLES LIKE 'interactive_timeout';
This will display the current values of the timeout-related variables.
Step 5: Restart MariaDB Server (If Necessary)
- In some cases, changes to global variables may require a restart of the MariaDB server to take effect.
- If necessary, restart the server using appropriate commands or through your server management interface.
Step 6: Test Connectivity
- Once adjusted the timeout variables and ensured that the changes are in effect, test the connectivity to MariaDB server to ensure that the “Lost Connection During Query” error has been solved.
How to fix MariaDB Lost Connection During Query?
The “Lost Connection During Query” error in MariaDB can disrupt database operations and lead to data loss or corruption. This error occurs when the communication between the database server and the client application is unexpectedly terminated.
In this article, We will learn about different strategies to solve the problem of Lost Connection During Query by understanding these strategies in depth manner.