简体   繁体   中英

mysqldump - create table if not exists

Im using mysqldump with powershell in order to create a backup script for my web app.

This is the command im using for the database dump:

mysqldump --user=$username --password=$password --log-error=$errorLog --result-file=$backupfile --databases $database

This creates the required script, however the "IF NOT EXISTS" bit is commented out and I dont know why, or how to stop this behaviour.

line form sqldump:

CREATE DATABASE /*!32312 IF NOT EXISTS*/ training_web /*!40100 DEFAULT CHARACTER SET utf8 */;

Any help would be greatly appreciated.

Thanks

Its a hint that mysql only works for that version (and later). 32312 => 3.23.12

This is totally normal behaviour that dump doesn't have IF NOT EXISTS ... the thing you are seeing is just a directive for MySQL telling it that the command only works in versions 3.23.12 or later.

If you would like to import the dump as it would have IF NOT EXISTS , just use --force switch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM