How to See Which MySQL Database Is Currently Selected?

Check which MySQL database is currently selected

You can find out which MySQL database is currently selected by using the DATABASE() function, for example, like so:

SELECT DATABASE();

If no database is selected, it will return NULL, otherwise it will produce an output like the following:

+------------+
| DATABASE() |
+------------+
| db_name    |
+------------+

Hope you found this post useful. It was published . Please show your love and support by sharing this post.