mySQL: Testing connection with query? mySQL: Testing connection with query? mysql mysql

mySQL: Testing connection with query?


is there any query I can run that will always output something sweet

This should do it

SELECT 'Something sweet'

Edit
If you don't want something sweet you can always use the built-in functions:

SELECT version()

for more ideas check out the manual:
http://dev.mysql.com/doc/refman/5.1/en/information-functions.html


To get more details you can also use SHOW statement:

SHOW VARIABLES LIKE 'version%';+---------------------------------+---------------------------+| Variable_name                   | Value                     |+---------------------------------+---------------------------+| version                         | 5.1.6-alpha-log           || version_comment                 | Source distribution       || version_compile_machine         | i686                      || version_compile_os              | suse-linux                |+---------------------------------+---------------------------+

http://dev.mysql.com/doc/refman/5.1/en/show-variables.html


Most db drivers have a ping() method where they have a mechanism that does exactly what your peers are suggesting.

However show variables and selecting from nothing doesnt expose anything health wise except the database engine, storage could be down, indexes could be corrupt, errors everywhere.