MongoDB: exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating

前端 未结 14 1790
轻奢々
轻奢々 2020-12-02 04:37

I created /data/db in root directory and ran ./mongod:

[initandlisten] exception in initAndListen: 20 Attempted to create a lock fi         


        
14条回答
  •  忘掉有多难
    2020-12-02 05:01

    First of all stop all the mongoDB services, then create a directory on / , it means root, if you don't have, and remove the port file also. give all permission to that directory, become that directory owner, run below command:

    sudo service mongod stop
    sudo rm -rf /tmp/mongod*
    sudo mkdir -p /data/db
    sudo chmod -R a+wxr /data
    sudo chown -R $USER:$USER /data
    

    Now you're done, just start the MongoDB service, if didn't help, try to change the port like:

    sudo service mongod restart && mongod # if didn't help run below cmd
    mongod --port 27018
    

    Note: For me all this stuff works and hoping would work for you, guy!

提交回复
热议问题