Command to delete all tables in a MySQL database
To delete all tables in a MySQL database, you can use the following command:
- Connect to MySQL server:
mysql -u username -p
The username is your MySQL username.
- Select the database where the table needs to be deleted:
use database_name;
The database_name is the name of the database where you want to delete the table.
- View all tables in the current database.
show tables;
This will list the names of all tables.
- Delete each table:
drop table table_name;
The table_name is the name of the table to be deleted. You can delete each table one by one based on the result of step 3.
- Exit the MySQL server:
exit;
In this way, you have successfully deleted all tables in the MySQL database.