How can I recover my MySQL databases from a Homestead Vagrant VirtualBox?

前端 未结 2 1872
梦谈多话
梦谈多话 2021-01-18 08:48

I was running Homestead v8.2.0 and laravel/homestead (virtualbox, 7.1.0) and Vagrant 2.2.4. I needed to upgrade because I wanted PHP 7.4 support.

Larave

2条回答
  •  情深已故
    2021-01-18 09:28

    Your only chance is to hope that vagrant box update does not do a fresh, clean install of mysql. I would try out a few things before giving up all hope:

    1) check your vm provider (VirtualBox??) see how many vms are listed there. IF there are more then you expect, boot up the odd ones from the VirtualBox interface and see if your data exists on the odd machine that you think shouldn't be there. This has very low chances of working to be honest, but it's worth a shot. It should cover you in the case that your old box still exists somewhere in its old state. If you find anything, do mysqldump and then restore in the new box.

    2) vagrant ssh in your new machine and cd /var/lib/ look for folders related to mysql. This should cover you in case the vagrant update command hasn't cleared your mysql data dir entirely. I fear it might have :( but do check if there's files that look like your old tables names or schema names. Id you find anything, change the mysql data dir to point to that folder, see this https://dba.stackexchange.com/questions/14320/how-can-i-move-a-mysql-database-to-another-drive . Do a mysqldump and restore in the new box

    3) use VBoxManage list vms to get a list of vagrant box ids. If the old one is still there, you may be able to point vagrant to it. Check this post: https://stackoverflow.com/a/37963066/4183810 . If you get access to your data, do a mysqldump of your data and restore it on the new box.

    There are some chances this could work, but unfortunately if you can't find your data, it's either gone or unreachable, so you might have to accept your fate :(

提交回复
热议问题