Home » Mysql » Where does MySQL store database files on Windows and what is the name of the files

Where does MySQL store database files on Windows and what is the name of the files

Posted by: admin November 1, 2017 Leave a comment

Questions:

So 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.

Any advice would be appreciated!

Answers:

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

Questions:
Answers:

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 (droping, importing), your problem should be solved.

Hope this helps 🙂

Questions:
Answers:

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.

Questions:
Answers:

For Windows 7:
c:\users\all users\MySql\MySql Server x.x\Data\

Where x.x is the version number of the sql server installed in your machine.

Fidel

Questions:
Answers:

That should be your {install path}\data e.g. C:\apps\wamp\bin\mysql\mysql5.5.8\data\{databasename}

Questions:
Answers:

Just perform a Windows Search for *.myi files on your local partitions. Period.

As I suspectected, they were located inside a program files folder, instead of using a proper data-only folder like most other database managers do.

Why do a my.ini file search, open it with an editor, look-up the path string, make sure you don’t alter the config file (!), and then do a second search? Complicated without a shred of added benefit other than to practice touch typing.

Questions:
Answers:

in MySQL are
“.myd” a database self and
“.tmd” a temporal file.
But sometimes I see also “.sql”.

It depends on your settings and/or export method.

Questions:
Answers:

It’s usually in the folder specified below, but ProgramData is usually a hidden folder. To show it, go to control panel search for “folder” then under advanced settings tick show hidden files and click apply.
C:/ProgramData/MySQL/MySQL Server 5.5/Data/

Questions:
Answers:

I just installed MySQL 5.7 on Windows7. The database files are located in the following directory which is a hidden one:
C:\ProgramData\MySQL\MySQL Server 5.7\Data

The my.ini file is located in the same root: C:\ProgramData\MySQL\MySQL Server 5.7

Questions:
Answers:

1) Locate the my.ini, which store in the MySQL installation folder.

For example,

C:\Program Files\MySQL\MySQL Server 5.1\my.ini

2) Open the “my.ini” with our favor text editor.

#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.1/"

#Path to the database root/"
datadir="C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.1/Data

Find the “datadir”, this is the where does MySQL stored the data in Windows.

Questions:
Answers:

C:\Program Files\MySQL\MySQL Workbench 6.3 CE\sys

paste URLin to window file,
and get Tables, Procedures, Functions from this directory