db:drop
Drop current database.
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:
| Option | Description |
|---|---|
--connection=CONNECTION | Select DB connection type for Magento configurations with several databases |
-t, --tables | Drop all tables instead of dropping the database |
--drop-views | Drop all views in the database |
-f, --force | Force 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
--tablesor--drop-views, the command will target the entire database.n98-magerun2.phar db:dropWith force:
n98-magerun2.phar db:drop --forceThis action drops all tables, views, and other database objects.
-
Drop only tables: Use the
--tablesoption.n98-magerun2.phar db:drop --tablesWith force:
n98-magerun2.phar db:drop --tables --force -
Drop only views: Use the
--drop-viewsoption.n98-magerun2.phar db:drop --drop-viewsWith force:
n98-magerun2.phar db:drop --drop-views --force -
Drop both tables and views (but not other DB objects like procedures, etc.): Specify both
--tablesand--drop-views.n98-magerun2.phar db:drop --tables --drop-viewsWith force:
n98-magerun2.phar db:drop --tables --drop-views --force