I have written a script to do regular exports of my database :
#!/bin/bash
current_date=`date '+%F-%H-%M-%S'`
cd /home/user/Documents/backup
mysqldump -umyusername -pmypassword mydb > db-backup-$current_date.sql
tar czvf db-backup-$current_date.tgz db-backup-$current_date.sql
rm db-backup-$current_date.sql
but I would like to export it with the following options available with phpMyAdmin :
- Enclose export in a transaction
- Disable foreign key checks
- Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement
How I can do that ?
EDIT
I can add the following lines at the beginning of mydatabase.sql file ?
SET FOREIGN_KEY_CHECKS=0;
SET AUTOCOMMIT=0;
START TRANSACTION;
If it is right to do that, so I guess my problem is how to insert lines in a given position ?
Yo can probably do most of it through mysqldump itself:
The
--create-optionsshould issue thedropcommand too.Have a look at
mysqldump --helpfor a list of all possible optionsAn alternative is to look in the PHP for
phpMyAdminand see what options it uses