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

872    Asked by SakshiD’souza in Devops , Asked on Jul 1, 2021

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

[initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating 
[initandlisten] shutdown: going to close listening sockets... [initandlisten] shutdown: going to flush diaglog... [initandlisten] now exiting [initandlisten] shutting down with
code:100

Answered by Uditi singh

 To attempted to create a lock file on a read-only directory: /data/db, terminating, you can use mongo as root, works for me:

    $ sudo mongod


Your Answer

Interviews

Parent Categories