简体   繁体   English

在可能不同的MySQL安装上还原MySQL数据库?

[英]Restoring a MySQL database on a potentially different MySQL installation?

I have a broken installation of Ubuntu 14.04 - it won't boot, but I won't say anymore about that because that's not what I'm asking about really. 我的Ubuntu 14.04安装失败,无法启动,但是我不再赘述,因为这并不是我真正要问的问题。 I have a MySQL database (created using v5.5) on the broken Ubuntu installation and I need that data. 我在损坏的Ubuntu安装上有一个MySQL数据库(使用v5.5创建),我需要该数据。 I can get at the raw MySQL database files by mounting the broken installation onto another machine. 通过将损坏的安装安装到另一台计算机上,可以获取原始的MySQL数据库文件。

I actually need the database to be imported into a MySQL v5.1 installation. 我实际上需要将数据库导入到MySQL v5.1安装中。 I tried copying the raw database files (eg the directory at /var/lib/mysql/dbname ) into the same directory on the working OS installation. 我尝试将原始数据库文件(例如/var/lib/mysql/dbname的目录)复制到正在运行的OS安装中的同一目录中。 At first, it seemed like it worked, I can see the database, I can use it and I can list the tables. 起初,它看起来像是可行的,我可以看到数据库,可以使用它,并且可以列出表。 But it turns out that even though I can see the tables in the db, any attempts to describe or use them in any way give the 'table doesnt exist` error. 但是事实证明,即使我可以看到数据库中的表,以任何方式描述或使用它们的任何尝试都会产生“表不存在”错误。

Ideally, I'd love to be able to use msqldump and then import the database the proper way, but how can I get a dump of the database if it's not part of the MySQL installation (remember, I can't boot into the installation, it's broken). 理想情况下,我希望能够使用msqldump然后以正确的方式导入数据库,但是如果它不是MySQL安装的一部分,那么如何获得数据库的转储(请记住,我无法启动安装程序,它已经坏了)。

Of course, mysqldump is the most preferable solution, but if it's not possible to use that utility with the raw database files as input, then I'm willing to try anything that might work. 当然,mysqldump是最可取的解决方案,但是如果无法使用该实用程序并将原始数据库文件作为输入,那么我愿意尝试任何可行的方法。

Of course the first thing you should do is to install the same version of MySQL as the original - if you're directly using the raw data files, keeping things as identical to the original as possible is a must! 当然,您应该做的第一件事是安装与原始版本相同的MySQL版本-如果您直接使用原始数据文件,则必须使它们与原始版本完全相同! The same applies to paths, make sure the new installation and data files are placed in the same directory path that they were originally. 路径同样适用,请确保新安装文件和数据文件与原始路径位于相同的目录路径中。

Once you have this, you can mysqldump the tables and use that to import into a clean, new installation. 一旦有了这个,就可以mysqldump这些表,并使用它导入到一个干净的新安装中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM