I’m working with MySQL Workbench 8.0.42 and need to run a query that takes more than 30 seconds to complete. I want to test how different MySQL time functions behave when there’s a delay in the query.
Here’s the code I’m trying to run:
SET SESSION connection_timeout = 90;
SET SESSION read_timeout = 90;
SET SESSION write_timeout = 90;
SET SESSION idle_timeout = 90;
SET SESSION query_execution_time = 90000;
SELECT
NOW() AS `NOW() - Beginning`,
CURRENT_TIMESTAMP AS `CURRENT_TIMESTAMP - Beginning`,
SYSDATE() AS `SYSDATE() - Beginning`,
CURRENT_TIME AS `CURRENT_TIME - Beginning`,
CURTIME(6) AS `CURTIME(6) - Beginning`,
SLEEP(85) AS `********** Wait 85 seconds **********`,
NOW() AS `NOW() - End`,
CURRENT_TIMESTAMP AS `CURRENT_TIMESTAMP - End`,
SYSDATE() AS `SYSDATE() - End`,
CURRENT_TIME AS `CURRENT_TIME - End`,
CURTIME(6) AS `CURTIME(6) - End`;
I added the timeout settings at the start to prevent connection issues, but the query still fails after exactly 30 seconds with this error:
15:22:41 SET SESSION connection_timeout = 90 0 row(s) affected 0.000 sec
15:22:41 SET SESSION read_timeout = 90 0 row(s) affected 0.000 sec
15:22:41 SET SESSION write_timeout = 90 0 row(s) affected 0.000 sec
15:22:41 SET SESSION idle_timeout = 90 0 row(s) affected 0.000 sec
15:22:41 SET SESSION query_execution_time = 90000 0 row(s) affected 0.000 sec
15:22:41 [The query] LIMIT 0, 1000 Error Code: 2013. Lost connection to MySQL server during query 30.001 sec
I tried using the hint syntax SELECT /*+ MAX_EXECUTION_TIME(90000) */ but it still times out at 30 seconds. I also checked for any variables set to 30 or 30000 but only found some unrelated settings like innodb_flushing_avg_loops and mysqlx_connect_timeout.
What’s the correct way to extend the query timeout in MySQL Workbench so my query can run for more than 30 seconds?
The 30-second timeout issue arises from the MySQL Workbench settings rather than the server configurations. I encountered the same problem while performing lengthy data migrations. To resolve it, navigate to Edit → Preferences → SQL Editor and look for the “DBMS connection read time out (in seconds)” option, which is likely set to 30 seconds by default. Increase it to 120 or even 300 seconds as required. Additionally, adjusting the “DBMS connection keep-alive interval” setting can help sustain the connection during extensive operations. Remember to restart your connection tab after applying the changes. While your server timeout variables seem appropriate, the Workbench client timeout takes precedence, and modifying it should eliminate the timeout issues during your tests.
Hit this same issue last year with large dataset imports. It’s definitely a Workbench problem, not your MySQL server config. Your session timeout variables look right, but Workbench just ignores them and uses its own client-side timeouts. After you change those preferences, test it first with SELECT SLEEP(45) before running your full query. Pro tip: the preference changes sometimes don’t stick if you’ve got multiple connection tabs open. Close everything and reconnect fresh. Your test query should work fine once the client timeout’s actually configured.
Yeah, this is super common with MySQL Workbench and long queries. Workbench’s client settings are overriding your server config - that’s why changing the SQL session variables isn’t working. You need to fix it in the app itself. Go to Edit > Preferences > SQL Editor and find the timeout settings. The main one is “DBMS connection read time out” - it’s probably set to 30 seconds. Bump it up to 120 or 180 seconds. After you change it, close your connection tab completely and open a new one. Your server settings are fine, but the client is cutting you off first.
for sure! it sounds like a workbench timeout prob. just head to Edit > Preferences > SQL Editor and increase the “DBMS connection read time out” option. it’s likely at 30 secs now, so try 90 or 120. don’t forget to restart the connection tab after changing it.
Had this exact problem a few months ago during performance testing. MySQL Workbench has its own client timeout that ignores your server settings. You need to change Workbench itself. Go to Edit > Preferences > SQL Editor. Look for “DBMS connection read time out” - it’s probably set to 30 seconds. Bump it to 120 or 180 seconds. Also check “DBMS connection keep-alive interval” while you’re in there. Close and reopen your connection tab after changing these settings. Your server-side variables are fine, but they’re useless if the client times out first.