You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将Cypherl文件直接导入Memgraph(Ubuntu与Docker实例)

导入Cypherl文件到Memgraph的两种方案

一、Ubuntu原生版Memgraph

直接用Memgraph自带的mgconsole命令行工具批量执行文件中的Cypher语句,完全不需要复制粘贴:

  • 先确认Memgraph服务处于运行状态
  • 在终端执行命令(替换为你的文件实际路径):
    mgconsole < /path/to/your/sample-data.cypherl
    
  • 如果需要指定非默认的连接参数(比如主机、端口),可以补充参数:
    mgconsole --host 127.0.0.1 --port 7687 < /path/to/your/sample-data.cypherl
    

二、Docker版Memgraph(Memgraph Platform镜像)

需要先把本地文件挂载或拷贝到容器内,再执行导入操作,有两种常用方式:

方式1:启动容器时直接完成导入

启动容器的同时挂载本地文件,并执行导入命令:

docker run -v /absolute/path/to/sample-data.cypherl:/data/sample-data.cypherl memgraph/memgraph-platform mgconsole < /data/sample-data.cypherl

注意:这里必须使用本地文件的绝对路径,否则Docker无法正确识别挂载路径。

方式2:在已运行的容器内导入

如果容器已经在运行,按以下步骤操作:

  1. 查看运行中的容器ID:
    docker ps
    
  2. 将本地文件拷贝到容器内(替换<container-id>为你的容器ID):
    docker cp /path/to/sample-data.cypherl <container-id>:/data/
    
  3. 进入容器的bash终端:
    docker exec -it <container-id> bash
    
  4. 在容器内执行导入命令:
    mgconsole < /data/sample-data.cypherl
    

通用注意事项

  • 确保文件内的Cypher语句语法正确,避免导入过程中报错中断
  • 原生版执行时,要保证当前用户对目标文件有可读权限
  • Docker挂载或拷贝文件后,确认容器内文件路径正确且具备可读权限

内容的提问来源于stack exchange,提问作者TenTonBonton

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 07:30:06