I'm using this command syntax :
mysqldump -u<username> -p<password> --no-create-db --databases mydatabase > /var/backups_DB/MyDatabase-$(date +"%d-%m-%Y-%H:%M:%S").sql
But I could not find how to prevent the line "use mydatabase" to be inserted in the generated file. Which option should I use?
As @wchiquito said in comments, in order to avoid to have the "
USE databasename
" statement in dump file you must remove the--databases
option.If you don't have the choice, you can remove it afterwards using a Unix sed command :
Thomas