Syntax error How can we change the default MySQL database to the given database?

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



Suppose currently we are using a tutorial database so it would be 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 subsequent queries.

mysql> USE Sample
Database changed

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

mysql> select database();

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

1 row in set (0.00 sec)
Updated on: 2020-02-05T08:18:09+05:30

509 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements