Where does MySQL store database files?


To know where MySQL store database files, you can use the variable @@datadir. The query is as follows −

mysql> select @@datadir;

The following is the output that displays the path −

+---------------------------------------------+
| @@datadir                                   |
+---------------------------------------------+
| C:\ProgramData\MySQL\MySQL Server 8.0\Data\ |
+---------------------------------------------+
1 row in set (0.00 sec)

Here is the snapshot where MySQL store database files i.e. the same path we got above −

Now, let us verify whether the above databases are present or not with the help of SHOW command.

The query is as follows −

mysql> SHOW DATABASES;

Here is the output −

+--------------------+
| Database           |
+--------------------+
| business           |
| database1          |
| databasesample     |
| education          |
| hello              |
| information_schema |
| javadatabase2      |
| javasampledatabase |
| mybusiness         |
| mydatabase         |
| mysql              |
| performance_schema |
| sample             |
| sampledatabase     |
| schemasample       |
| sys                |
| test               |
| test3              |
| universitydatabase |
+--------------------+
19 rows in set (0.12 sec)

Look at the above output, all databases are matched.

Updated on: 30-Jul-2019

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements