使用 MySQL 附加现有数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13789234/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 15:43:34  来源:igfitidea点击:

Attaching an existing database with MySQL

mysql

提问by Martin Robins

Disclaimer: I have never used MySQL before!

免责声明:我以前从未使用过 MySQL!

I have a folder containing a number of .frm, .myd and .myi files that I believe are a MySQL database. I have pulled these files from a defunct server for a client who has not used the server or database for some years but is now looking to resurect some of the data for a new venture.

我有一个文件夹,其中包含许多我认为是 MySQL 数据库的 .frm、.myd 和 .myi 文件。我已经从一个已经失效的服务器中为一个客户提取了这些文件,该客户已经多年没有使用服务器或数据库,但现在正在寻求为新企业恢复一些数据。

I have downloaded the latest free edition of MySQL, along with MySQL Workbench and am looking to connecct the existing database to the new installation; the equivalent to an "Attach" if I were using MS SQL Server.

我已经下载了 MySQL 的最新免费版本以及 MySQL Workbench,并希望将现有数据库连接到新安装;如果我使用的是 MS SQL Server,则相当于“附加”。

I have found a few articles that say if I simply copy the folder into the data folder for MySQL and restart the service the database will show up. I have tried this (using both the data folder within the installation folder and also the "MySQL Datafiles" folder created during the intial configuration but when I restart the service nothing shows up.

我发现一些文章说,如果我只是将文件夹复制到 MySQL 的数据文件夹中,然后重新启动服务,数据库就会显示出来。我已经尝试过这个(使用安装文件夹中的数据文件夹以及在初始配置期间创建的“MySQL Datafiles”文件夹,但是当我重新启动服务时没有任何显示。

How should I go about attaching this database?

我应该如何去附加这个数据库?

采纳答案by Martin Robins

Ok. I found the answer, the folder I was adding the database to was the wrong one. Though I had found 2 "data" folders, there was a 3rd hiding in C:\ApplicationData; once I added my data files in here and restarted the MySQL service I could see the data.

好的。我找到了答案,我添加数据库的文件夹是错误的。虽然我找到了 2 个“数据”文件夹,但在 C:\ApplicationData 中隐藏了第三个;一旦我在这里添加了我的数据文件并重新启动了 MySQL 服务,我就可以看到数据了。

回答by Zar Shardan

On Windows 8 the default folder where MySql databases are stored is:

在 Windows 8 上,存储 MySql 数据库的默认文件夹是:

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

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

5.6 is the version.

5.6是版本。

Please note it is ProgramDatanot Program Fileswhich is easy to overlook.

请注意它是ProgramData而不是Program Files,这很容易被忽视。

Copying there and restarting the service worked fine for me. I'm even copying the DBs from an earlier 5.X version.

在那里复制并重新启动服务对我来说效果很好。我什至从早期的 5.X 版本中复制 DB。