Is it necessary to select the database each time we begin a MySQL session?
How can it be done?


The database is created only once but it is necessary to select it each time we begin a MySQL

session. It can be done with the help of USE db_name statement on MySQL command line tool.

mysql> Use Query;
Database changed

It shows that we are now using query database.

We can also select the database while invoking the MySQL from Windows command line. It can be done with the help of the following command −

C:\Program Files\MySQL\bin>mysql -u root -p query
Enter password: *****

Here, query is the name of the database we are going to use for current MySQL session

Updated on: 28-Jan-2020

54 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements