MySQL show current connection info

brutustea picture brutustea · Sep 1, 2010 · Viewed 176.6k times · Source

I am in a MySQL terminal session but I don't know what server I am connected to, or what database I am connected to.

Is there a MySQL command that will tell me the host, port, and username and database I am using now?

Answer

2ndkauboy picture 2ndkauboy · Sep 1, 2010

There are MYSQL functions you can use. Like this one that resolves the user:

SELECT USER();

This will return something like root@localhost so you get the host and the user.

To get the current database run this statement:

SELECT DATABASE();

Other useful functions can be found here: http://dev.mysql.com/doc/refman/5.0/en/information-functions.html