使用数据文件的副本恢复mysql数据库

时间:2015-08-14 22:10:22

标签: mysql mysql-backup

我的计算机的主硬盘驱动器昨天死了,我有一个新的并恢复它但是当我去恢复我的mysql数据库时,我意识到我有一段时间没有做适当的备份。 不过,我确实拥有以前安装的原始数据库文件,因为数据文件位于第二个硬盘中。

我的问题是,我是否可以仅使用之前安装的文件在新机器中恢复/创建新数据库?

感谢, 伊格纳西奥

1 个答案:

答案 0 :(得分:0)

Yes, you should be able to do this.

I'm a bit unclear: when you say, "I do have the original database files" do you mean as a database? If so, go to phpMySql for the surviving database and choose Export. Export the database as a text file. Open the file with your favorite text editor and change the name of the database to match the name you are importing into.

Create the empty database where you want the new one to be, if it doesn't already exist. Now go to phpMySql for that database and import your text file. This should recreate all the tables and their data in the new location.

If instead, you only have the files that were the source of the data, then you need to use whatever tool was used to create the database in the first place. For example, if the data is in the form on an Excel spreadsheet, you would use MySql for Excel.

Hope this helps!

(after your comment that you have file backups of WordPress site)

In that case, you may not be so lucky. If you used a tool to do your backup, it may have backed up the database, but in general, the database is stored separately from your file system. So if you just copied the files yourself, you won't have the database. But do look for any file with a suffix of .SQL, which would be a database backup.

Next, contact your Internet Service Provider and see if they do periodic database backups. If so, you can recover from them.

For the future, see if your ISP provides automated backups (including database). And read https://codex.wordpress.org/WordPress_Backups.