如何通过mgconsole向WSL中运行的Memgraph导入.cypherl格式数据
导入.cypherl数据到WSL Ubuntu中的Memgraph(无需Memgraph Lab)
方法1:通过mgconsole交互式导入
- 确认Memgraph服务状态并启动(若未运行):
sudo systemctl status memgraph sudo systemctl start memgraph - 启动Memgraph自带的命令行客户端:
mgconsole - 在Cypher提示符下,执行导入命令(替换为你的.cypherl文件绝对路径):
SOURCE "/home/your-user/data/your-data.cypherl"; - 验证导入结果:
MATCH (n) RETURN count(n);
方法2:终端管道非交互式导入
无需进入交互模式,直接通过管道执行整个.cypherl文件:
mgconsole < "/path/to/your-data.cypherl"
方法3:使用memgraph-import批量导入(需停服务)
- 先停止Memgraph服务:
sudo systemctl stop memgraph - 执行导入命令:
memgraph-import --cypher-file "/path/to/your-data.cypherl" - 重新启动服务:
sudo systemctl start memgraph
常见问题处理
- 若
mgconsole提示连接失败,检查端口是否被修改,指定端口连接:mgconsole --port 自定义端口号 - 确保文件路径为WSL格式:使用WSL内部路径(如
/home/xxx/)或Windows挂载路径(如/mnt/c/Users/xxx/),不要直接使用Windows的C:\路径。
内容的提问来源于stack exchange,提问作者KWriter
相关产品推荐
相关产品推荐

