MySQL 在 Windows 上存储数据库文件的位置以及文件的名称是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12947668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where does MySQL store database files on Windows and what is the name of the files?
提问by Brad
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!
任何意见,将不胜感激!
回答by Udan
You can check my.ini
file to see where the data folder is located.
您可以检查my.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:\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}
.
文件夹 C:\ProgramData 是一个隐藏文件夹,因此您必须在 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 提供此内容
回答by Julio
In Windows 7, the MySQL database is stored at
在 Windows 7 中,MySQL 数据库存储在
C:\ProgramData\MySQL\MySQL Server 5.6\data
C:\ProgramData\MySQL\MySQL Server 5.6\data
Note: this is a hiddenfolder. And my example is for MySQL Server version 5.6; change the folder name based on your version if different.
注意:这是一个隐藏文件夹。我的例子是 MySQL Server 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 (dropping, importing), your problem should be solved.
知道这个位置很有用,因为有时 MySQL Workbench 无法删除模式(或导入数据库)。这主要是由于 db 文件夹中存在文件,这些文件由于某种原因无法在 Workbench 的早期进程中删除。使用 Windows 资源管理器删除文件并重试(删除、导入),您的问题应该可以解决。
Hope this helps :)
希望这可以帮助 :)
回答by Mukus
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。
回答by user3256430
For Windows 7: c:\users\all users\MySql\MySql Server x.x\Data\
对于 Windows 7:c:\users\all users\MySql\MySql Server xx\Data\
Where x.x is the version number of the sql server installed in your machine.
其中 xx 是您机器中安装的 sql server 的版本号。
Fidel
菲德尔
回答by AleDB
Just perform a Windows Search for *.myi files on your local partitions. Period.
只需在本地分区上对 *.myi 文件执行 Windows 搜索。时期。
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.
为什么要搜索 my.ini 文件,用编辑器打开它,查找路径字符串,确保没有更改配置文件 (!),然后再进行第二次搜索?除了练习触摸打字外,没有一点额外的好处。
回答by codingbiz
That should be your {install path}\data e.g. C:\apps\wamp\bin\mysql\mysql5.5.8\data\{databasename}
那应该是您的 {安装路径}\data 例如 C:\apps\wamp\bin\mysql\mysql5.5.8\data\{databasename}
回答by B.K
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/
它通常在下面指定的文件夹中,但 ProgramData 通常是一个隐藏文件夹。要显示它,请转到控制面板搜索“文件夹”,然后在高级设置下勾选显示隐藏文件并单击应用。C:/ProgramData/MySQL/MySQL Server 5.5/Data/
回答by Erik
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:\ProgramData\MySQL\MySQL Server 5.7\Data
The my.ini
file is located in the same root: C:\ProgramData\MySQL\MySQL Server 5.7
该my.ini
文件位于同一根目录中:C:\ProgramData\MySQL\MySQL Server 5.7
回答by Dongdong
MYSQL 8.0:
MYSQL 8.0:
Search my.ini
in disk, we will find this folder:
my.ini
在磁盘中搜索,我们会找到这个文件夹:
C:\ProgramData\MySQL\MySQL Server 8.0
It'sProgramData
, notProgram file
C:\ProgramData\MySQL\MySQL Server 8.0
是ProgramData
,不是Program file
Data is in sub-folder: \Data
.
数据在子文件夹中:\Data
.
Each database
owns a folder, each table
is file, each index
is 1+ files.
每个database
拥有一个文件夹,每个table
是文件,每个index
是 1+ 个文件。
回答by Saliu Muideen
If you're using Win10 with Xampp server installed, then you can find the data folder in C:\xampp\mysql\data
如果您使用安装了 Xampp 服务器的 Win10,那么您可以在C:\xampp\mysql\data 中找到数据文件夹
Inside the data folder, each database has its own folder which in turn contains the .frm, .myi and .myd files which represent for a single table in the database.
在数据文件夹中,每个数据库都有自己的文件夹,这些文件夹依次包含代表数据库中单个表的 .frm、.myi 和 .myd 文件。
If for instance, you created a database with the name: myschool and inside the database, you have three tables with the names:
例如,如果您创建了一个名为 myschool 的数据库,并且在数据库内部,您将拥有三个名称为的表:
- Nursery
- Primary
- Secondary
- 苗圃
- 基本的
- 中学
Then, you will have for the Nursery table: nursery.frm, nursery.myi and nursery.myd. Same will go for the Primary and Secondary tables. Thus, in the I mentioned here, you will a total of 9 files inside the database folder named myschool.
然后,您将拥有 Nursery 表:nursery.frm、nursery.myi 和nursery.myd。主表和次表也是如此。因此,在我这里提到的数据库文件夹中,您将总共有 9 个文件,名为myschool。
You can then copy the database folder and use it in your new mysql installation data folder.
然后,您可以复制数据库文件夹并在新的 mysql 安装数据文件夹中使用它。
I hope this helps.
我希望这有帮助。
Best regards.
此致。