Skip to content

Reset all Magento 2 settings

If you’re ever developing or testing different Magento 2 environments and you need to quickly reset back to the fresh install state, 3 CLI commands can get you there:

# Drop database
mysql -e "DROP DATABASE $DB_NAME;CREATE DATABASE $DB_NAME;"

# Re-create database
php bin/magento setup:db-schema:upgrade

# Re-install site
php bin/magento setup:install \
  --base-url="http://$SERVER_HOSTNAME/" \
  --base-url-secure="https://$SERVER_HOSTNAME/" \
  --db-host=localhost \
  --db-name="$DB_NAME" \
  --db-user="$DB_USERNAME" \
  --db-password="$DB_PASSWORD" \
  --admin-firstname="$ADM_FIRST" \
  --admin-lastname="$ADM_LAST" \
  --admin-email="$ADM_EMAIL" \
  --admin-user="$ADM_USER" \
  --admin-password="$ADM_PASS" \
  --currency="$MG_CURRENCY" \
  --session-save=redis \
  --timezone="$PHP_TIMEZONE" \
  --use-rewrites=1

# Profit!
Published inDevelopment