gpt4 book ai didi

mysqldump在没有表结构的情况下提取数据

转载 作者:IT老高 更新时间:2023-10-28 23:51:58 25 4
gpt4 key购买 nike

我正在尝试将一个数据库的所有 mysql 数据转储到一个文件中。也就是说,我不想在此文件中包含表结构(还有另一个文件将包含表的结构)。

是否可以严格提取数据而不是表结构?

我现在在做什么...

# Extracts the database structure
mysqldump -d -hlocalhost -uusername -ppassword database -r database.sql

# Extracts each table and their data individually
mysqldump -d -hlocalhost -uusername -ppassword database --tab .

第一个命令将吐出一个包含数据库中所有实体结构的 .sql 文件,而第二个命令会自动生成包含结构和实体拆分的 .sql 和 .txt 文件。

我需要的是整个数据库的一个副本,以相同的方式完成。

谢谢

最佳答案

使用 --no-create-info选项,或其简写 -t:

  • --no-create-info, -t

    Do not write CREATE TABLE statements that re-create each dumped table.

    Note

    This option does not not exclude statements creating log file groups or tablespaces from mysqldump output; however, you can use the --no-tablespaces option for this purpose.

关于mysqldump在没有表结构的情况下提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12122772/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com