MySQL在Windows上存储数据库文件,文件的名称是什么?

时间:2021-09-14 21:42:04

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.

所以我不小心格式化了硬盘,重新安装了windows,忘记备份mySQL服务器上的一个重要数据库。我现在正试图用一些软件来回收文件,但我不知道该找什么。

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.

我相信我的服务器使用的是MyISAM,但不是100%确定。

Any advice would be appreciated!

如有任何建议,我们将不胜感激!

11 个解决方案

#1


56  

You can check my.ini file to see where the data folder is located.

你可以检查我的。ini文件,查看数据文件夹的位置。

Usually there is a folder {mysqlDirectory}/data

通常有一个文件夹{mysqlDirectory}/data

MySQL data storage:

MySQL数据存储:

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.

frm文件包含表定义。你的*。myi文件是MyISAM索引文件。你的*。myd文件包含表数据。

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

在Windows 8.1中,MySQL数据库(默认)存储在这里:C:\编程式数据\MySQL服务器5.6\ MySQL Server 5.6\数据

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

文件夹C:\编程数据是一个隐藏的文件夹,所以必须将它输入Windows资源管理器地址才能到达那里。在该数据文件夹中,数据库被命名为/{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

感谢@marty-mcgee的内容

#2


34  

In Windows 7, the MySQL database is stored at

在Windows 7中,MySQL数据库存储在

C:\ProgramData\MySQL\MySQL Server 5.6\data

C:\ ProgramData \ MySQL 5.6 \ \ MySQL服务器数据

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.

注意:这是一个隐藏的文件夹。我的例子是MySQL服务器版本5.6;如果不同,请根据您的版本更改文件夹名称。

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.

知道这个位置很有用,因为有时MySQL工作台不能删除模式(或导入数据库)。这主要是由于db文件夹中存在文件,由于某些原因,工作台无法在较早的进程中删除这些文件。使用Windows资源管理器删除文件并再次尝试(拖放、导入),您的问题应该得到解决。

Hope this helps :)

希望这有助于:)

#3


10  

I have a default my-default.ini file in the root and there is one server configuration:

我有一个默认的my-default。ini文件在根目录中,有一个服务器配置:

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

storage_engine变量将告诉您是否使用了InnoDb或MyISAM。

#4


6  

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

适用于Windows 7: c \用户所有用户\MySql Server x. \数据\

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

在x。x是机器中安装的sql服务器的版本号。

Fidel

菲德尔

#5


3  

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

这应该是你的{安装路径}数据,例如C:\apps\wamp\bin\mysql\mysql5.5.8\data\{databasename}

#6


2  

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

只需执行一个Windows搜索*。myi文件在您的本地分区上。时期。

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.

为什么我的。ini文件搜索,使用编辑器打开它,查找路径字符串,确保不修改配置文件(!),然后进行第二次搜索?除了练习触控打字之外,没有任何附加的好处。

#7


2  

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

我刚在Windows7上安装了MySQL 5.7。数据库文件位于以下目录中,这是一个隐藏的目录:C:\编程式数据\MySQL\MySQL Server 5.7\数据

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

我的。ini文件位于同一根目录下:C:\程序数据\MySQL\MySQL服务器5.7。

#8


1  

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

在MySQL”。myd"一个数据库自我和"。tmd”一个临时文件。但有时我也会看到"。sql"

It depends on your settings and/or export method.

这取决于您的设置和/或导出方法。

#9


1  

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/

它通常在下面指定的文件夹中,但是程序化数据通常是一个隐藏的文件夹。要显示它,请转到“文件夹”的控制面板搜索,然后在高级设置下勾选“显示隐藏文件”并单击“应用”。C:/ ProgramData / MySQL / 5.5 /数据/ MySQL服务器

#10


0  

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

1)找到我。ini,它存储在MySQL安装文件夹中。

For example,

例如,

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

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

2)打开“我的。和我们喜欢的文本编辑器。

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

找到“datadir”,这是MySQL在Windows中存储数据的地方。

#11


0  

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

6.3 CE \ sys C:\Program Files\MySQL\MySQL工作台

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

将URLin粘贴到窗口文件,并从这个目录中获取表、过程和函数

#1


56  

You can check my.ini file to see where the data folder is located.

你可以检查我的。ini文件,查看数据文件夹的位置。

Usually there is a folder {mysqlDirectory}/data

通常有一个文件夹{mysqlDirectory}/data

MySQL data storage:

MySQL数据存储:

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.

frm文件包含表定义。你的*。myi文件是MyISAM索引文件。你的*。myd文件包含表数据。

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

在Windows 8.1中,MySQL数据库(默认)存储在这里:C:\编程式数据\MySQL服务器5.6\ MySQL Server 5.6\数据

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

文件夹C:\编程数据是一个隐藏的文件夹,所以必须将它输入Windows资源管理器地址才能到达那里。在该数据文件夹中,数据库被命名为/{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

感谢@marty-mcgee的内容

#2


34  

In Windows 7, the MySQL database is stored at

在Windows 7中,MySQL数据库存储在

C:\ProgramData\MySQL\MySQL Server 5.6\data

C:\ ProgramData \ MySQL 5.6 \ \ MySQL服务器数据

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.

注意:这是一个隐藏的文件夹。我的例子是MySQL服务器版本5.6;如果不同,请根据您的版本更改文件夹名称。

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.

知道这个位置很有用,因为有时MySQL工作台不能删除模式(或导入数据库)。这主要是由于db文件夹中存在文件,由于某些原因,工作台无法在较早的进程中删除这些文件。使用Windows资源管理器删除文件并再次尝试(拖放、导入),您的问题应该得到解决。

Hope this helps :)

希望这有助于:)

#3


10  

I have a default my-default.ini file in the root and there is one server configuration:

我有一个默认的my-default。ini文件在根目录中,有一个服务器配置:

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

storage_engine变量将告诉您是否使用了InnoDb或MyISAM。

#4


6  

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

适用于Windows 7: c \用户所有用户\MySql Server x. \数据\

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

在x。x是机器中安装的sql服务器的版本号。

Fidel

菲德尔

#5


3  

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

这应该是你的{安装路径}数据,例如C:\apps\wamp\bin\mysql\mysql5.5.8\data\{databasename}

#6


2  

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

只需执行一个Windows搜索*。myi文件在您的本地分区上。时期。

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.

为什么我的。ini文件搜索,使用编辑器打开它,查找路径字符串,确保不修改配置文件(!),然后进行第二次搜索?除了练习触控打字之外,没有任何附加的好处。

#7


2  

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

我刚在Windows7上安装了MySQL 5.7。数据库文件位于以下目录中,这是一个隐藏的目录:C:\编程式数据\MySQL\MySQL Server 5.7\数据

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

我的。ini文件位于同一根目录下:C:\程序数据\MySQL\MySQL服务器5.7。

#8


1  

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

在MySQL”。myd"一个数据库自我和"。tmd”一个临时文件。但有时我也会看到"。sql"

It depends on your settings and/or export method.

这取决于您的设置和/或导出方法。

#9


1  

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/

它通常在下面指定的文件夹中,但是程序化数据通常是一个隐藏的文件夹。要显示它,请转到“文件夹”的控制面板搜索,然后在高级设置下勾选“显示隐藏文件”并单击“应用”。C:/ ProgramData / MySQL / 5.5 /数据/ MySQL服务器

#10


0  

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

1)找到我。ini,它存储在MySQL安装文件夹中。

For example,

例如,

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

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

2)打开“我的。和我们喜欢的文本编辑器。

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

找到“datadir”,这是MySQL在Windows中存储数据的地方。

#11


0  

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

6.3 CE \ sys C:\Program Files\MySQL\MySQL工作台

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

将URLin粘贴到窗口文件,并从这个目录中获取表、过程和函数