I am trying to empty the database of any data, while keeping the relationships and tables as they are
I have no idea if my thinking is right or wrong
CodePudding user response:
Yes, you just run mysqldump with --no-data
mysqldump --no-data -u someuser -p mydatabase
You can save it to a .sql file and then drop your database Then you restore it from the dump
CodePudding user response:
truncate table_name;
table_name is the table you want to delete all data in it. truncate only works on tables, so you need to execute truncate table one by one.
CodePudding user response:
Use truncate to all table :
mysqldump -d -uuser -ppass --add-drop-table databasename > databasename.sql
mysql -uuser -ppass databasename < databasename.sql
or you can read this, similar problem.