Home  >  Article  >  Database  >  Do we need to select the database every time we start a MySQL session? How can this be done?

Do we need to select the database every time we start a MySQL session? How can this be done?

WBOY
WBOYforward
2023-09-16 13:29:021359browse

Do we need to select the database every time we start a MySQL session? How can this be done?

The database is only created once, but you need to select it each time you start a MySQL session

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

mysql> Use Query;
Database changed

This indicates that we are now using to query the database.

We can also select the database when calling MySQL from the Windows command line. This 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 will use for the current MySQL session

The above is the detailed content of Do we need to select the database every time we start a MySQL session? How can this be done?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete