Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 mysqldump 工具来创建我的数据库的转储,例如
mysqldump database > database.sql
尽管添加了选项“--lock-tables=FALSE”,.sql 文件包含如下行:
LOCK TABLES "tableXYZ" WRITE; UNLOCK TABLES;
是否可以在将这些行写入 .sql 文件之前过滤掉它们?
mysqldump database | sed -r '/^(UN)?LOCK/d' > database.sql
使用sed你可以这样做:
sed
mysqldump database |sed -e "/LOCK/d"> database.sql
此命令将在放入之前删除所有包含“LOCK”的行database.sql
database.sql