View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 07:35 AM
Gordon Burditt
 
Posts: n/a
Default Re: How to find out if mysql connection is "healthy"?

>That's about the C api.
>
>I have a need to find out if a mysql connection is healthy or not,
>that is, is the server still up and able to serve queries, or not.
>
>How would I do it?
>
>mysql_error returns a lot of codes and it is unclear which ones are
>the ones to look for.


mysql_ping() seems to be useful for this sort of thing, assuming
the connection is not currently in use with a query. If you've
timed out it will reconnect. Or, give it some kind of trivial query
that proves you have access to the tables you need, e.g. DESCRIBE
tablename or SELECT * FROM tablename LIMIT 1 .

Gordon L. Burditt
Reply With Quote