Find & Change MySQL Database Location on Windows 10
Where is your MySQL database stored on Windows 10? By default, MySQL stores its databases within a specific directory structure, typically in the 'C:' drive. However, this can be altered during the installation process or afterward. Let's discuss exactly where you can find your MySQL databases and how you can manipulate the storage location if needed.
MySQL databases are stored in the Databases sub-directory under the data directory. This data directory is where MySQL stores all its critical files, including the databases, log files, and temporary files. But where exactly is this data directory located in Windows 10?
Default MySQL Data Directory Location in Windows 10
The default location of the MySQL data directory in Windows 10 is within your MySQL installation folder. If you did not specify a different location during the installation process, the data directory is usually at:
C:\Program Files\MySQL\MySQL Server X.X\data
Finding the MySQL Data Directory
To locate the data directory, you can use the following steps:
- Open MySQL Command Line Client and log in as the root user.
- Run the SELECT command:
SHOW VARIABLES LIKE 'datadir'; - The query results will display the location of the data directory.
Modifying the MySQL Data Directory Location
If you wish to change the data directory location for some reason, you can do so by updating the 'datadir' variable in the MySQL configuration file:
- Open the MySQL configuration file named my.ini. It is typically located at
C:\Program Files\MySQL\MySQL Server X.X\my.ini - Search for the 'datadir' field. It might look like:
datadir="C:\Program Files\MySQL\MySQL Server X.X\data" - Change the path to your desired location, for example:
datadir="D:\MySQL\Data" - Save and close the file, then restart the MySQL service for the changes to take effect.
Understanding the MySQL Databases Sub-Directory
Once you've located the data directory, you'll find the databases reside in a subdirectory named 'databases'. Here, each database is stored as a separate file with a '.frm', '.myd', and '.myi' extension:
- .frm - Table definition (Metadata)
- .myd - Data file
- .myi - Index file