USE MyDatabase;
How do I UNUSE MyDatabase
or DESELECT MyDatabase
so I can use SHOW DATABASES
again? What is the opposite of USE
?
There is no UNUSE
. You just select another database and USE
it.
mysql -u <whatever>
is there any way to get back to that state?
Bruce Daniels presented an answer at https://web.archive.org/web/20160130220207/https://dev.mysql.com/doc/refman/5.5/en/use.html.
It goes like:
CREATE DATABASE foofoofooweird;
USE foofoofooweird;
DROP DATABASE foofoofooweird;
Et voila, no database is in use.
To be clear, the hack is to CREATE, USE, then DROP (delete) a temporary placeholder database.
It is NOT advocating dropping (deleting) any database you actually use!
All credits to Bruce Daniels!
MySQL cmd can't make "unuse" function, if you want to change between databases, just use the USE DATABASENAME;
command.
As said in other answers, you simply can switch to another database, but if you just want to use none of the databases you can quit from mysql session and start it again.
\q
mysql -u username -p password
I don't see clear reason to do this, but it answers the question.
There is no command UNUSE as USE db_name,
but instead you can use the same USE statement but with the replacing db name.
Suppose i am now working in world db and want to chanage to employee
intially i have entered USE world now i will simply enter use employees
show databases
shows all the databases regardless of whether you have selected one. Be more specific about your problem.