Retrieve the name of the current database by using the DATEBASE() function: DATABASE()
mysql> mysql> mysql> SELECT DATABASE(); +------------+ | DATABASE() | +------------+ | test | +------------+ 1 row in set (0.00 sec) mysql>