MySQL Mysqldump:备份时为插入创建列名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5467517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mysqldump: create column names for inserts when backing up
提问by Quintin Par
How do I instruct mysqldump to backup with column names in insert statements?
In my case I didn't a normal back up with insert sql's resulting in
如何指示 mysqldump 使用插入语句中的列名进行备份?
就我而言,我没有使用插入 sql 进行正常备份,导致
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users`
INSERT INTO `users` VALUES (1
structure.
结构体。
Now I went ahead and removed a columnfrom the schema in users. After this when I run the backup sql's I get a column number mismatch error.
现在我继续从用户模式中删除一列。此后,当我运行备份 sql 时,出现列号不匹配错误。
To fix this how do I go about instructing mysqldump to write column names too? Here is how I do it now
要解决这个问题,我该如何指示 mysqldump 也写入列名?这是我现在的做法
mysqldump --host=${dbserver} --user=${dbusername} --password=${dbpassword} \
--no-create-db --no-create-info --extended-insert --single-transaction \
--compress tablename
On a broader level, what's the best practice to manage these schema changes?
在更广泛的层面上,管理这些架构更改的最佳实践是什么?
回答by Cherian
Use --complete-insert
in the mysqldump command params
使用--complete-insert
在mysqldump命令PARAMS