Andy
A-ndy.dev

A-ndy.dev

Drop all tables in MySQL

Andy's photo
Andy
·Aug 7, 2021·

1 min read

Export database with empty table data

$ mysqldump --add-drop-table --no-data -u root -p db_name | grep 'DROP TABLE' ) > drop_all_tables.sql

Restore the empty database

$ mysql -u root -p db_name < drop_all_tables.sql

Restore your new tables

mysql -u root -p db_name < database_new.sql

 
Share this