Remove your magento installation

in Troubleshooting

The following snippets are used to remove your Magento installation(s).

This is irreversible so make sure you know what you are doing!

Remove a Magento 1 installation

In order to uninstall/remove a Magento 1 installation, run the following command:

n98-magerun --root-dir=/data/web/public uninstall --installationFolder=/data/web/public --force

This will delete the default database (YOURAPPNAME_preinstalled_Magento), and recursively delete the /data/web/public directory.
Any instances of Magento installed in other directories will not be touched.

Remove a Magento 2 installation

For Magento 2 there is not a magerun plugin available to uninstall the files yet.
We can therefore remove the installation by hand.

For the production installation:

cd ~/magento2 && n98-magerun2 db:drop
cd ~ && rm -rf /data/web/{magento2,public} && mkdir /data/web/public

Or to remove a staging environment:

cd ~/magento2_staging && n98-magerun db:drop
cd ~ && rm -rf /data/web/{magento2_staging,staging} && mkdir /data/web/staging

Manually remove any installation

To manually remove all databases and files of both the staging and production, use the following snippet:

mysql -Be 'show databases' | sed 1d |\
 grep -vE '^information_schema$|^performance_schema$|^mysql$|^test$' | while read DATABASE
do
    mysql -Be "DROP DATABASE $DATABASE"
done

Then remove all Magento files, use the following command:

cd /data/web
rm -rf /data/web/{public,staging,magento2,magento2_staging}
mkdir /data/web/{public,staging}

Keep in mind: After removing your Magento content and database, sometimes you need to remove or adjust your nginx configuration in /data/web/nginx too to start with a clean slate.

0