To show which databases exist on a vagrant virtual server, do the following steps. This supposes you already have a vagrant server up and running, for example VVV. It will list all current databases, like those of wordpress installs.
- ssh into the server with
vagrant ssh
- from the root directory, type
mysql
to launch the MySQL monitor (often, MariaDB). - type
show databases;
and then press enter. Included databases appear in a neat table. Remember to add the “;” which is mysql’s way of marking the end of a command.
If you reprovision your vagrant, you should know that it will try to recreate the placeholder websites you used to set up your local copy. If you’re running git, it will give you an error message that it can’t download the vagrant custom template.
At this point it’s too late to cancel, but:
- you can still salvage your database, provided the prefix isn’t “wp_” anymore. Indeed, tables with “wp_” will get squashed as vagrant uploads the dummy database if they have the same name. If you have a different prefix, your original tables won’t be lost, and you can just remove the wp_ones afterwards.
- make sure you have a copy of your local wp-config.php file beforehand: adjusting those parameters is long, and if you saved a copy, you can just paste it back in place even before opening the website.
- lastly, the theme for your website is hopefully stored on a git repository. When the new provision is finished, just delete the placeholder content and clone your website back to your local folder from the repository.