Home >Database >Mysql Tutorial >How can we change the default MySQL database to a given database?

How can we change the default MySQL database to a given database?

WBOY
WBOYforward
2023-09-04 10:53:02713browse

我们如何将默认的 MySQL 数据库更改为给定的数据库?

Assuming we are currently using a tutorial database, then it will become the default MySQL database for subsequent queries. Now, with the help of USE db_name statement, we can change the default database to other given database for subsequent queries.

mysql> USE Sample
Database changed

The database has been changed from tutorial to example. To verify this we can run the following command −

mysql> select database();

+------------+
| database() |
+------------+
| sample     |
+------------+

1 row in set (0.00 sec)

The above is the detailed content of How can we change the default MySQL database to a given database?. 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