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

WSL2 Ubuntu运行Memgraph遭遇systemd初始化错误求助

问题原因

WSL2 默认并未以 systemd 作为初始化系统(PID 1),而 sudo systemctl start memgraph 依赖 systemd 管理服务,这就是报错的核心原因——你没操作错,只是双启动Ubuntu和WSL2的初始化系统存在差异。

解决方案

方法1:直接手动启动Memgraph

跳过systemd,直接调用Memgraph的启动程序:

  • 切换到memgraph用户:
    sudo su - memgraph
    
  • 前台启动Memgraph:
    /usr/bin/memgraph
    
  • 若需后台运行,添加--daemon参数:
    /usr/bin/memgraph --daemon
    
  • 停止服务可执行:
    pkill memgraph
    

方法2:让WSL2支持systemd

如果想继续用systemctl管理服务,可给WSL2启用systemd:

  1. 编辑WSL配置文件:
    sudo nano /etc/wsl.conf
    
  2. 写入以下配置:
    [boot]
    systemd=true
    
  3. 保存退出(按Ctrl+O回车,再按Ctrl+X),然后关闭所有WSL终端,在Windows PowerShell中执行:
    wsl --shutdown
    
  4. 重新打开Ubuntu终端,systemd已生效,此时就能正常用sudo systemctl start memgraph启动服务了。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 17:56:06