I have a development database (MYSQL) which I would like to load with fresh data at some point. I would like to delete the content of all tables. What is the best way, as autom
Here's what I do from the command prompt:
mysql -Nse 'show tables' DATABASE_NAME | while read table; do mysql -e "SET FOREIGN_KEY_CHECKS = 0; TRUNCATE table $table" DATABASE_NAME; done
Problem is, if you require authentication, you will need to add a -u YOUR_USERNAME -pYOURPASSWORD
after both mysql
commands.
If you don't want to enter your password at the command prompt (I don't ever), then you'll need to copy and paste the password after every prompt, which may be several times depending on the number of tables.