{"id":27643271,"url":"https://github.com/matrixorigin/mo_dump","last_synced_at":"2025-08-19T08:39:08.028Z","repository":{"id":207743291,"uuid":"719984336","full_name":"matrixorigin/mo_dump","owner":"matrixorigin","description":"Generate SQL statements capable of recreating database objects and data.","archived":false,"fork":false,"pushed_at":"2025-06-11T08:35:44.000Z","size":136,"stargazers_count":1,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-11T09:43:56.777Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matrixorigin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-17T10:25:12.000Z","updated_at":"2025-06-11T08:35:47.000Z","dependencies_parsed_at":"2024-02-27T09:48:14.432Z","dependency_job_id":"953b4918-ec9c-4d33-8366-f47f023a5f6b","html_url":"https://github.com/matrixorigin/mo_dump","commit_stats":null,"previous_names":["matrixorigin/mo_dump"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/matrixorigin/mo_dump","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrixorigin%2Fmo_dump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrixorigin%2Fmo_dump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrixorigin%2Fmo_dump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrixorigin%2Fmo_dump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matrixorigin","download_url":"https://codeload.github.com/matrixorigin/mo_dump/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrixorigin%2Fmo_dump/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271123385,"owners_count":24703219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-24T00:11:49.389Z","updated_at":"2025-08-19T08:39:08.004Z","avatar_url":"https://github.com/matrixorigin.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mo_dump\nMatrixOne supports logical backups through the mo_dump utility. mo_dump is a command-line utility designed to generate logical backups of the MatrixOne database. It produces SQL statements that can be used to recreate database objects and data.\n\n## 使用方法\n\n### 语法结构\n\n```\n./mo-dump -u ${user} -p ${password} -h ${host} -P ${port} -db ${database} [--local-infile=true] [--enable-escape=false] [-csv] [-no-data] [-tbl ${table}...] -net-buffer-length ${net-buffer-length} \u003e {dumpfilename.sql}\n```\n\n**参数释义**\n\n- **-u [user]**：连接 MatrixOne 服务器的用户名。只有具有数据库和表读取权限的用户才能使用 `mo-dump` 实用程序，默认值 dump。\n\n- **-p [password]**：MatrixOne 用户的有效密码。默认值：111。\n\n- **-h [host]**：MatrixOne 服务器的主机 IP 地址。默认值：127.0.0.1\n\n- **-P [port]**：MatrixOne 服务器的端口。默认值：6001\n\n- **-db [数据库名称]**：必需参数。要备份的数据库的名称。可以指定多个数据库，数据库名称之间用 `,` 分隔。\n\n- **-net-buffer-length [数据包大小]**：数据包大小，即 SQL 语句字符的总大小。数据包是 SQL 导出数据的基本单位，如果不设置参数，则默认 1048576 Byte（1M），最大可设置 16777216 Byte（16M）。假如这里的参数设置为 16777216 Byte（16M），那么，当要导出大于 16M 的数据时，会把数据拆分成多个 16M 的数据包，除最后一个数据包之外，其它数据包大小都为 16M。\n\n- **-csv**：默认值为 false。当设置为 true 时表示导出的数据为 *CSV* 格式。\n\n- **--local-infile**：默认值为 true，仅在参数 **-csv** 设置为 true 时生效。表示支持本地导出 *CSV* 文件。\n\n- **-tbl [表名]**：可选参数。如果参数为空，则导出整个数据库。如果要备份指定表，则可以在命令中指定多个 `-tbl` 和表名。\n\n- **-no-data**：默认值为 false。当设置为 true 时表示不导出数据，仅导出表结构。\n\n- **-enable-escape**：默认值为 false，仅在参数 **-csv** 设置为 true 时生效。表示对特殊字符开启转义，可以避免一些兼容性问题。\n\n\n### 构建 mo-dump 二进制文件\n__Tips:__ 由于 `mo-dump` 是基于 Go 语言进行开发，所以你同时需要安装部署 \u003ca href=\"https://go.dev/doc/install\" target=\"_blank\"\u003eGo\u003c/a\u003e 语言。\n\n1. 执行下面的代码即可从 MatrixOrigin/mo_dump 源代码构建 `mo-dump` 二进制文件：\n\n    ```\n    git clone https://github.com/matrixorigin/mo_dump.git\n    cd mo_dump\n    make build\n    ```\n\n2. 你可以在 mo_dump 文件夹中找到 `mo-dump` 可执行文件：*mo-dump*。\n\n!!! note\n    构建好的 `mo-dump` 文件也可以在相同的硬件平台上工作。但是需要注意在 x86 平台中构建的 `mo-dump` 二进制文件在 Darwin ARM 平台中则无法正常工作。你可以在同一套操作系统和硬件平台内构建并使用 `mo-dump` 二进制文件。`mo-dump` 目前只支持 Linux 和 macOS。\n\n## 如何使用 `mo-dump` 导出 MatrixOne 数据库\n\n`mo-dump` 在命令行中非常易用。参见以下步骤示例，导出 *sql* 文件格式完整数据库：\n\n在你本地计算机上打开终端窗口，输入以下命令，连接到 MatrixOne，并且导出数据库：\n\n```\n./mo-dump -u username -p password -h host_ip_address -P port -db database \u003e exporteddb.sql\n```\n\n例如，如果你在与 MatrixOne 实例相同的服务器中启动终端，并且你想要生成单个数据库的备份，请运行以下命令。该命令将在 *t.sql* 文件中生成 **t** 数据库的结构和数据的备份。*t.sql* 文件将与您的 `mo-dump` 可执行文件位于同一目录中。\n\n```\n./mo-dump -u root -p 111 -h 127.0.0.1 -P 6001 -db t \u003e t.sql\n```\n\n如果你想将数据库 *t* 内的表导出为 *CSV* 格式，参考使用下面的命令：\n\n```\n./mo-dump -u root -p 111  -db t -csv --local-infile=false \u003e ttt.csv\n```\n\n如果要在数据库中生成单个表的备份，可以运行以下命令。该命令将生成命名为 *t* 的数据库的 *t1* 表的备份，其中包含 *t.sql* 文件中的结构和数据。\n\n```\n./mo-dump -u root -p 111 -db t -tbl t1 \u003e t1.sql\n```\n\n* `mo-dump`  支持导出多个数据库。[在 -db后接数据库名]\n例如\n```mysql\nmo-dump -u dump -p xxx -h 127.0.0.1 -P 6001 -db db1,db2,db3 \u003e /tm/db1-db2-db3.sql\nmo-dump -u dump -p xxx -h 127.0.0.1 -P 6001 -db all \u003e /tm/all-dbs.sql\n```\n\n* `mo-dump`  不仅支持导出多个数据库，还支持导出多个数据库表。\n例如\n```mysql\nmo-dump -u dump -p xxx -h 127.0.0.1 -P 6001 -db db1 -tbl tbl1,tbl2,tbl3 \u003e /tm/all-dbs.sql\n```\n\n## 限制\n* `mo-dump` 暂不支持只导出数据库的结构或数据。如果你想在没有数据库结构的情况下生成数据的备份，或者仅想导出数据库结构，那么，你需要手动拆分 `.sql` 文件。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrixorigin%2Fmo_dump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrixorigin%2Fmo_dump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrixorigin%2Fmo_dump/lists"}