Sometime in MySQL command prompt we are working with some random MySQL Queries, but suddenly we need to know which database we were working on. It could quit easy if we were known to this database for long , but what if don’t know, actually there is one way in MySQL SQL prompt to identify current working database. let’s check How…

Login on Database

When we just login on MySQL, no working on any database, it will show no database in query select database()

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select database();
+------------+
| database() |
+------------+
| NULL       |
+------------+
1 row in set (0.00 sec)

It show NULL, means no current working database.

But once we start working on database and get into them through use command and then same select database() start showing database name like mentioned below.

mysql> use mysql
Reading table information for completion of table and column
You can turn off this feature to get a quicker startup with 

Database changed
mysql> select database();
+------------+
| database() |
+------------+
| mysql      |
+------------+
1 row in set (0.00 sec)

In above we select with use command to work on mysql database and hence below command show it as selected which denote that now we selected mysql Database.