大网数据广告活动
服务器运维问答

MariaDB - import raw InnoDB frm/ibd files?

· 52CE 我爱测

Good afternoon. My Debian 9 server ran into an issue that rendered the OS inaccessible , I managed to extract all the raw database files (/var/lib/mysql) for my project but unfortunately the engine type was set to InnoDB. Is ther…

问题原文

原帖链接 · Kjell · CC BY-SA 4.0

Good afternoon.

My Debian 9 server ran into an issue that rendered the OS inaccessible , I managed to extract all the raw database files (/var/lib/mysql) for my project but unfortunately the engine type was set to InnoDB.

Is there any chance I can somehow recover the database? Thanks.

已采纳解答

原帖链接 · Zoredache · CC BY-SA 4.0

If you have the entire /var/lib/mysql then you should probably try completely replacing the current contents of /var/lib/mysql with the content you have.

Depending on your mariadb/mysql options some or all of the innodb data is global and stored in the /var/lib/mysql/ibdata1, and /var/lib/mysql/ib_logfile files. So just restoring the /var/lib/mysql/databasename/table* will usually not be enough to restore innodb data.

You could temporarily move the current current contents of that directory to another location if you already have restored or started using that. Or even better temporarily start up a new machine in a VM or something where you can test restoring the entire /var/lib/mysql directory without interrupting anything.

After placing your old data in /var/lib/mysql you should be able to start the server and hopefully extract your data. You may need to start mariadb with the options to bypass privileges depending on how locked down your privileges were. I wouldn't continue to use that though, instead I would suggest at that point you use mysqldump or your favorite tools to dump the database, then re-import it into your production database.

As you move things back and for make sure that the mysql/mariadb service account (normally mysql/mysql) owns and has read-write access to all the files.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。