微信登录

apoc导出数据

导出前的apoc.conf配置

  1. # 允许APOC读写磁盘文件
  2. apoc.export.file.enabled=true
  3. apoc.import.file.enabled=true
  4. # 放开所有apoc存储过程权限(可选,防止权限报错)
  5. dbms.security.procedures.unrestricted=apoc.*

创建或者修改conf后要重启数据库

导出命令:

不带上id

  1. CALL apoc.export.cypher.all("full_graph_dump.cypher", { format: "cypher-shell", useTypes: true, exportConstraints: true, exportIndexes: true }) YIELD file, nodes, relationships RETURN file, nodes, relationships;

命令会导出到import文件夹,文件名是full_graph_dump.cypher

带上id

  1. CALL apoc.export.cypher.all("full_graph_dump_with_ids.cypher", {
  2. format: "cypher-shell",
  3. useTypes: true,
  4. exportConstraints: true,
  5. exportIndexes: true,
  6. writeNodeIds: true, // ✅ 输出 node id
  7. writeRelationshipIds: true // ✅ 输出 rel id
  8. }) YIELD file, nodes, relationships
  9. RETURN file, nodes, relationships;

目标库必须清空MATCH (n) DETACH DELETE n;

windows cmd 导入数据命令

  1. cypher-shell -a neo4j://localhost:7687 -u neo4j -p "12345678" -f "F:\app\neo4j-community-5.26.13\import\full_graph_dump_with_ids20260903.cypher"