UP | HOME

wsl debian10 mongodb4 start fail solve

Table of Contents

wsl debian10 mongodb4 start fail solve

启动

  ➜  ~ sudo systemctl start mongod
     #报错如下
     System has not been booted with systemd as init system (PID 1). Can't operate.
     Failed to connect to bus: 主机关闭

处理

  ➜  ~ sudo curl -o /etc/init.d/mongodb https://raw.githubusercontent.com/mongodb/mongo/master/debian/init.d
  ➜  ~ sudo chmod +x etc/init.d/mongodb
  ➜  ~ sudo service mongodb start
     #如下
     [ ok ] Starting database: mongod.

测试

  ➜  ~ mongo --eval 'db.runCommand({ connectionStatus: 1 })'
     MongoDB shell version v4.4.3
     connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
     Implicit session: session { "id" : UUID("01e2fbd4-7cd3-47e1-8b03-e94dbe5bd6bb") }
     MongoDB server version: 4.4.3
     {
         "authInfo" : {
             "authenticatedUsers" : [ ],
             "authenticatedUserRoles" : [ ]
         },
         "ok" : 1
  }

First created: 2021-01-27 Wed 00:00
Last updated: 2021-11-25 Thu 23:21
Power by Emacs 27.1 (Org mode 9.4)
© 2017 – 2021 by josephzeng