我不知道如何对具有 where 条件的特定表执行 mysqldump。这是我的指示:
mysqldump --user=... --password=... --host=... DB_NAME user --where "name not in ('root', 'root2')",customer --where "customer_name not in ('root', 'root2')" >dump.sql
我收到此错误:
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM
user
WHERE customer_name not in ('root', 'root2')': Unknown column 'customer_name' in 'where clause' (1054)
出了什么问题?谢谢
最佳答案
您不能为每个表创建新的 WHERE 条件。有一个 WHERE 条件,它将应用于每个表。因此,您只能引用备份中包含的每个表中都存在的列。
您可以为每个表运行一个 mysqldump 命令,但如果这样做,您将无法获得一致的备份。我的意思是,您不能使用锁或事务来确保备份包含来自单个时间点的数据。因此,如果数据库在此期间正在使用,则您稍后备份的表可能会引用自您备份早期表以来创建的新行。
关于mysql dump 导出更多带有where条件的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70759286/