Computer >> Computer tutorials >  >> Programming >> MySQL

Where is the MySQL database gets saved when it is created?


If you want the database location i.e. where it is created in MySQL, you can use system variable @@datadir.

The syntax is as follows

SELECT @@datadir;

The following is the query

mysql> select @@datadir;

Here is the output. The above query returns the location

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

Now reach the above directory in your system. The screenshot of the directory is as follows

Where is the MySQL database gets saved when it is created?

Now open the Data folder. The Data folder contains all the databases. The screenshot displaying all the databases is as follows

Where is the MySQL database gets saved when it is created?

Now you can check any database folder for the tables. For example, let us see the table names of the ‘sample’ database. The screenshot is as follows

Where is the MySQL database gets saved when it is created?