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

MySQLMySQLi Database

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

raja
Published on 19-Feb-2018 11:33:41
Advertisements