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:
- 编辑WSL配置文件:
sudo nano /etc/wsl.conf - 写入以下配置:
[boot] systemd=true - 保存退出(按
Ctrl+O回车,再按Ctrl+X),然后关闭所有WSL终端,在Windows PowerShell中执行:wsl --shutdown - 重新打开Ubuntu终端,systemd已生效,此时就能正常用
sudo systemctl start memgraph启动服务了。
内容的提问来源于stack exchange,提问作者KWriter
相关产品推荐
相关产品推荐

