MySQL 从数据文件夹备份中恢复mysql数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9041976/
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
Recovering mysql database from data folder backup
提问by Alireza Noori
I have uninstalled the old XAMPP and deleted all of the content of d:\xampp folder
and installed the new one. When I copy my backup folder (with the name of my database, containing all .frm
and .opt
files) to the D:\xampp\mysql\data
, the database shows in the list in phpmyadmin but it has no tables and data. What I've done wrong?
我已经卸载了旧的 XAMPP 并删除了所有内容d:\xampp folder
并安装了新的。当我将备份文件夹(以我的数据库名称,包含所有文件.frm
和.opt
文件)复制到D:\xampp\mysql\data
. 我做错了什么?
采纳答案by Alireza Noori
I've searched a lot. There's a few other files that are needed for recovery. I think it's impossible to recover tables from the .frm files alone. I've re-created my database.
我已经搜索了很多。还有一些其他文件需要恢复。我认为仅从 .frm 文件中恢复表是不可能的。我重新创建了我的数据库。
回答by Ahmad Baktash Hayeri
Here's how I dealt with this kind of situation:
我是这样处理这种情况的:
- Stopthe Apacheand MySqlservices from xampp control panel.
- Back up (just in case), then delete the
data
folder from your new xampp installation folder<physical_drive>/xampp/mysql
.(The
data
folder contains the schema/table definitions (.frm files) for your tables.) - Copy the
data
folder from your previousxampp
folder (or the backup) undermysql
and paste it to the new location (i.e.<physical_drive>/xampp/mysql
). - Now startthe Apacheand MySqlservices from the xampp control panel.
- 停止的阿帕奇和MySQL的从XAMPP控制面板服务。
- 备份(以防万一),然后
data
从新的 xampp 安装文件夹中删除该文件夹<physical_drive>/xampp/mysql
。(该
data
文件夹包含表的架构/表定义(.frm 文件)。) data
从之前的xampp
文件夹(或备份)中复制文件夹mysql
并将其粘贴到新位置(即<physical_drive>/xampp/mysql
)。- 现在开始的Apache的与MySQL的从XAMPP的控制面板服务。
There you go, the tables should show up with their structures as you click on them.
好了,当您单击表格时,表格应该会显示其结构。
Note: Make sure you leave the bin
folder under your xampp installation folder untouched.
注意:确保您bin
的 xampp 安装文件夹下的文件夹保持不变。
回答by Rahul Shewale
It is possible, I found out a solution:
有可能,我找到了一个解决方案:
- Install new xampp
- Copy your old database folder from
xampp\mysql\data\databasefolder to Paste in your running xampp folder
C:\xampp\mysql\data - After that stop mysql and apache service then backup your running xampp files ib_logfile0,ib_logfile1 and ibdata1 and store in safe place
- Then Copy same file (ib_logfile0,ib_logfile1 and ibdata1) from old xampp\mysql\data\ and paste in your running xampp server C:\xampp\mysql\data\
- Start mysql and apache service Open CMD Fire command C:\xampp\mysql\bin>mysqldump -u dbusername -p dbpassword dbname>D:\exportdb.sql
- stop mysql and apache service and restore your main ib_logfile0,ib_logfile1 and ibdata1 file (check Step 3)
- after than again start service and open http://localhost/phpmyadmin/and import database backup from D:\exportdb.sql Now your backup is working :)
- 安装新的 xampp
- 将旧数据库文件夹从 xampp\mysql\data\databasefolder 复制到正在运行的 xampp 文件夹
C:\xampp\mysql\data 中粘贴 - 之后停止 mysql 和 apache 服务,然后备份您正在运行的 xampp 文件 ib_logfile0、ib_logfile1 和 ibdata1 并存储在安全的地方
- 然后从旧的 xampp\mysql\data\ 复制相同的文件(ib_logfile0、ib_logfile1 和 ibdata1)并粘贴到您正在运行的 xampp 服务器 C:\xampp\mysql\data\
- 启动mysql和apache服务 打开CMD Fire命令 C:\xampp\mysql\bin>mysqldump -u dbusername -p dbpassword dbname>D:\exportdb.sql
- 停止 mysql 和 apache 服务并恢复您的主要 ib_logfile0、ib_logfile1 和 ibdata1 文件(检查步骤 3)
- 之后再次启动服务并打开http://localhost/phpmyadmin/并从 D:\exportdb.sql 导入数据库备份现在您的备份正在工作:)
回答by Spec
Set datadir = "D:\xampp\mysql\data" in xampp/mysql/bin/my.ini
在 xampp/mysql/bin/my.ini 中设置 datadir = "D:\xampp\mysql\data"
回答by Nishanth
I ran into the same problem. I had all my projects in mysql which I lost somehow.
我遇到了同样的问题。我的所有项目都在 mysql 中,但不知何故我丢失了。
mysql under my old xampp had got deleted/uninstalled somehow. I did not even have the data folder to copy to new xampp location.
我的旧 xampp 下的 mysql 以某种方式被删除/卸载。我什至没有将数据文件夹复制到新的 xampp 位置。
I browsed through the folders and found mysql/data and mysql/backup in below location.
我浏览了文件夹,在下面的位置找到了 mysql/data 和 mysql/backup。
C:\xampp\perl\mysql\data
C:\xampp\perl\mysql\backup
C:\xampp\perl\mysql\data
C:\xampp\perl\mysql\backup
This is what I did.
这就是我所做的。
I copied both these folders in place of new xampp mysql/data and mysql/backup folders.
我复制了这两个文件夹来代替新的 xampp mysql/data 和 mysql/backup 文件夹。
I also copied other files (not folders) under /mysql from old xampp to new xampp /mysql.
我还将 /mysql 下的其他文件(不是文件夹)从旧的 xampp 复制到新的 xampp /mysql。
Stop new xampp mysql and apache servers if running. Restart.
如果正在运行,请停止新的 xampp mysql 和 apache 服务器。重新开始。
Viola I got all the lost databases back.
Viola 我找回了所有丢失的数据库。
Hope this helps.
希望这可以帮助。
回答by Manoj
I have found a solution for this. I Installed new XAMPP and Replace old bin folder in Apache and mysql folders in old XAMPP with new folders from newly Installed Xampp I have recoverd all my data.
我已经找到了解决方案。我安装了新的 XAMPP 并将旧 XAMPP 中的旧 bin 文件夹和旧 XAMPP 中的旧 bin 文件夹替换为新安装的 Xampp 中的新文件夹我已经恢复了所有数据。
回答by munandi sichali
I just copied the data folder from the mysql folder inside the xampp folder structure and paste it in the same structure in my new installation, Everything is working fine now.
我只是从 xampp 文件夹结构内的 mysql 文件夹中复制了数据文件夹,并将其粘贴到我的新安装中的相同结构中,现在一切正常。
回答by Md . Sojib Ahmed
- Copy your all old database from old to newly installed Xampp under this dir
- 将所有旧数据库从旧数据库复制到此目录下新安装的 Xampp
C:\xampp\mysql\data\
C:\xampp\mysql\data\
- Copy this file an keep back up form hear C:\xampp\mysql\data
- 复制这个文件并保持备份形式听到 C:\xampp\mysql\data
ib_logfile0, ib_logfile1 and ibdata1
ib_logfile0、ib_logfile1 和 ibdata1
- Similarly copy and replace ib_logfile0, ib_logfile1 and ibdata1 from old xampp to new xampp
If previous Db has crushed or error like mysqld.exe has stopped working use bellow 2 line inside my.ini file of mysql
[mysqld]
innodb_force_recovery = 2
innodb_file_per_table=1
Restart Apache and MYSQL and go to PHPMyadmin to export your previous database.
- finally replace your back up ib_logfile0, ib_logfile1 and ibdata1 that was taken bakup previously
- 同样将ib_logfile0、ib_logfile1和ibdata1从旧的xampp复制并替换到新的xampp
如果以前的 Db 已崩溃或错误,如 mysqld.exe 已停止工作,请在 mysql 的 my.ini 文件中使用以下 2 行
[mysqld]
innodb_force_recovery = 2
innodb_file_per_table=1
重新启动 Apache 和 MYSQL 并转到 PHPMyadmin 以导出您以前的数据库。
- 最后替换之前备份的 ib_logfile0、ib_logfile1 和 ibdata1