[英]mysqldump - create table if not exists
Im using mysqldump with powershell in order to create a backup script for my web app. 我使用带有Powershell的mysqldump来为我的Web应用程序创建备份脚本。
This is the command im using for the database dump: 这是im用于数据库转储的命令:
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. 这将创建所需的脚本,但是“ IF NOT EXISTS”位被注释掉了,我不知道为什么,或如何停止这种行为。
line form sqldump: 线形sqldump:
CREATE DATABASE /*!32312 IF NOT EXISTS*/
training_web /*!40100 DEFAULT CHARACTER SET utf8 */;
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). 它暗示mysql仅适用于该版本(及更高版本)。 32312 => 3.23.12
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 NOT EXISTS
完全正常的行为...您所看到的只是MySQL的一条指令,告诉它该命令仅在3.23.12版或更高版本中有效。
If you would like to import the dump as it would have IF NOT EXISTS
, just use --force
switch. 如果您要导入转储文件(
IF NOT EXISTS
,请使用--force
开关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.