Skip to main content

db:drop

Drop current database.

warning

This command will permanently delete the current database. Use with extreme caution, especially with the --force option, as it will drop the database without confirmation. Ensure you have backups before proceeding.

n98-magerun2.phar db:drop [options]

Options:

OptionDescription
--connection=CONNECTIONSelect DB connection type for Magento configurations with several databases
-t, --tablesDrop all tables instead of dropping the database
--drop-viewsDrop all views in the database
-f, --forceForce execution without confirmation

Help and Usage Scenarios:

The command prompts before performing any drop operation unless the --force option is specified. The configured user in app/etc/env.php must have "DROP" privileges.

The db:drop command can be used to drop the entire database, only tables, or only views:

  • Drop entire database: If run without --tables or --drop-views, the command will target the entire database.

    n98-magerun2.phar db:drop

    With force:

    n98-magerun2.phar db:drop --force

    This action drops all tables, views, and other database objects.

  • Drop only tables: Use the --tables option.

    n98-magerun2.phar db:drop --tables

    With force:

    n98-magerun2.phar db:drop --tables --force
  • Drop only views: Use the --drop-views option.

    n98-magerun2.phar db:drop --drop-views

    With force:

    n98-magerun2.phar db:drop --drop-views --force
  • Drop both tables and views (but not other DB objects like procedures, etc.): Specify both --tables and --drop-views.

    n98-magerun2.phar db:drop --tables --drop-views

    With force:

    n98-magerun2.phar db:drop --tables --drop-views --force