Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to associate a time out to a query sent to the MySQL server?

Expected behavior

  • MySQL server would trigger a time out if the query did not complete after a time T provided by the caller
  • No result would be returned to the caller
  • An error would be triggered instead (and caught by the caller).

Didn't find this in the MySQL documentation.
However it seems relevant: in case some indexes are missing or for some other reason, a time out would prevent the server to collapse (some queries may take hours to complete and will get cumulated in the server stack).

share|improve this question
up vote 1 down vote accepted

Have a look at this link from stackoverflow. It may not meet all your requirements (stated above), but I think it will help.

If you specify which programming language you are using to connect to MySQL server, you may find a better way to do it.

share|improve this answer
Thanks. I guess if java can do it, it is possible in any language. – ringø Nov 22 '10 at 2:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.