Where does MySQL store database files on Windows and what are the names of the files?
I accidentally formatted my hard drive and re-installed Windows and forgot to backup an important database I had in my MySQL server. I'm trying to salvage files now using some software, but I don't know what to look for.
What is the path that the files are stored in, and what are the files named (what naming convention, or file extension should I look for)?
I believe my server was using MyISAM, but not 100% sure.
Solution 1:
You can check my.ini
file to see where the data folder is located.
Usually there is a folder {mysqlDirectory}/data
MySQL data storage:
Commands.frm
Commands.myd
Commands.myi
The *.frm files contain the table definitions. Your *.myi files are MyISAM index files. Your *.myd files contain the table data.
Edit/Update. Because of the interest shown in the question here is more info which is found also in the comments.
In Windows 8.1, the MySQL databases are stored (by default) here: C:\ProgramData\MySQL\MySQL Server 5.6\data
The folder C:\ProgramData is a hidden folder, so you must type it into Windows Explorer address to get there. In that data folder, the databases are named /{database_name_folder}/{database_tables_and_files}
.
For instance,
C:\ProgramData\MySQL\MySQL Server 5.6\data\mydatabase\mytable.frm
C:\ProgramData\MySQL\MySQL Server 5.6\data\mydatabase\mytable.ibd
Thank @marty-mcgee for this content
Solution 2:
In Windows 7, the MySQL database is stored at
C:\ProgramData\MySQL\MySQL Server 5.6\data
Note: this is a hidden folder. And my example is for MySQL Server version 5.6; change the folder name based on your version if different.
It comes in handy to know this location because sometimes the MySQL Workbench fails to drop schemas (or import databases). This is mostly due to the presence of files in the db folders that for some reason could not be removed in an earlier process by the Workbench. Remove the files using Windows Explorer and try again (dropping, importing), your problem should be solved.
Solution 3:
I have a default my-default.ini file in the root and there is one server configuration:
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
So that does not tell me the path.
The best way is to connect to the database and run this query:
SHOW VARIABLES WHERE Variable_Name LIKE "%dir" ;
Here's the result of that:
basedir C:\Program Files (x86)\MySQL\MySQL Server 5.6\
character_sets_dir C:\Program Files (x86)\MySQL\MySQL Server 5.6\share\charsets\
datadir C:\ProgramData\MySQL\MySQL Server 5.6\Data\
innodb_data_home_dir
innodb_log_group_home_dir .\
lc_messages_dir C:\Program Files (x86)\MySQL\MySQL Server 5.6\share\
plugin_dir C:\Program Files (x86)\MySQL\MySQL Server 5.6\lib\plugin\
slave_load_tmpdir C:\Windows\SERVIC~2\NETWOR~1\AppData\Local\Temp
tmpdir C:\Windows\SERVIC~2\NETWOR~1\AppData\Local\Temp
If you want to see all the parameters configured for the database execute this:
SHOW VARIABLES;
The storage_engine variable will tell you if you're using InnoDb or MyISAM.