Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in SQL by (55.6k points)

Can anyone explain what is the default database in MySQL?

2 Answers

0 votes
by (119k points)

You can use the SHOW DATABASES statement lists all databases in the MySQL database server before you create a new database.

Here is the syntax to list all the databases in the server:

SHOW DATABASES;

You can observe the databases in the MySQL database server. The information_schema and MySQL are the default database in MySQL.

Selecting a database to work with

If you want to use a particular database you want to work with, you can do using the USE statement as below.

USE database_name;

If you want to learn MySQL from top professionals, then check out this SQL Certification program by Intellipaat.

Also, watch this video on MySQL:

0 votes
by (1.7k points)

In MySQL you do not have a "default database." The default is the one you specify as part of your session.

1. Selecting a Database: You can switch the default database using the `USE` statement:

USE my_database;

3. Connection String: To specify the default database on your connection string, you would do something like this:

mysql -u username -p my_database
 

3. No Implicit Default: The statements using a database fail if no database has been chosen.

The MySQL client takes the database chosen by `USE` or specified in the connection parameters as default for the session

Related questions

0 votes
3 answers
asked Jun 26, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer
0 votes
1 answer
asked Feb 7, 2021 in SQL by dev_sk2311 (45k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...