Knowing the current selected database becomes very important when there are more than one databases created and you want to know on which database your queries were executed or will be executed in future.

MySQL provides a command using which you can use to know the current selected database.

MySQL command to view the current selected database is


This command can be executed both from MySQL workbench or MySQL command line.
From Workbench
Open MySQL workbench and execute the above command. It will show the current selected database as shown below.
show database from workbenchAs can be seen from above image, the selected database is returned. Note that selected database is also displayed in bold at left side.

From MySQL terminal
Open MySQL terminal, login using your username and password and execute the above command. It will display the selected database as shown below.
show database from terminalIf no database is selected, such as when you login to the terminal for the first time, this command will return null.
Hit the clap if the article was useful.


Share your thoughts !!

Close Menu

Never Miss an article !

Get the new post delivered straight into your inbox, enter your email and hit the button

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

codippa will use the information you provide on this form to be in touch with you and to provide updates and marketing.