mongod shell doesn't start, data/db doesn't exsist

后端 未结 3 1725
心在旅途
心在旅途 2020-12-10 21:13

When I start mongod trowed error. What is the problem?

root@cs12867:~# mongod
mongod --help for help and startup options
Sun Dec 22 15:37:44.081 [initandlist         


        
3条回答
  •  难免孤独
    2020-12-10 21:39

    The default db path for mongodb is /data/db/.

    So when you run:

    mongod
    

    MongoDB checks if /data/db/ is present and if the user has access to it. In your case, there is no such directory and hence the error.

    However you can override the default db path using the --dbpath argument of mongod( or use a config file).

    mongod --dbpath /var/lib/mongodb/data/db
    

    In this case instead of checking for /data/db/ mongoDB check for /var/lib/mongodb/data/db. In your case, you have the specified directory and you have access to it and hence it runs.

    And doing this doesn't start the mongo shell. To start the shell, start mongod first as mentioned above and leave it running. Then in another terminal execute

    mongo
    

    This will start the mongo shell.

提交回复
热议问题