Select MySQL Database

In this article, we will see how to Select MySQL Database. We can select a MySQL Database using SELECT database command.

Syntax to Select MySQL Database:

SELECT database_name;

Examples to Select MySQL Database:

1. Get list of databases using SHOW DATABASES command.

SHOW DATABASES;

Select MySQL Database

2. From the above output, To make r2schools as the current database, use below statement:

USE r2schools;

Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed

3. To verify we have selected correct database or not use below command.

SELECT database();

4. Select database, when we login into the database.

mysql -u root -p -D r2schools

verify by using SELECT database(); command.

So in this article, we have seen How to select a MySQL database using USE statement and while logging to MySQL Server.