I created this dir
/home/user/mongodb
and used
sudo chown -R mongodb:mongodb /home/user/mongodb/
to change ownership to mongodb.
This
/data/db
already existed in root dir, but tried to remove and then recreate and use it due to permission issues (see below)
mongod
2022-03-29T13:20:26.963+0300 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2022-03-29T13:20:26.995+0300 I CONTROL [initandlisten] MongoDB starting : pid=4456 port=27017 dbpath=/data/db 64-bit host=snf-870308
2022-03-29T13:20:26.997+0300 I CONTROL [initandlisten] db version v4.2.0
2022-03-29T13:20:26.997+0300 I CONTROL [initandlisten] git version: a4b751dcf51dd249c5865812b390cfd1c0129c30
2022-03-29T13:20:26.998+0300 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2022-03-29T13:20:26.998+0300 I CONTROL [initandlisten] allocator: tcmalloc
2022-03-29T13:20:26.998+0300 I CONTROL [initandlisten] modules: none
2022-03-29T13:20:26.998+0300 I CONTROL [initandlisten] build environment:
2022-03-29T13:20:26.998+0300 I CONTROL [initandlisten] distmod: ubuntu1604
2022-03-29T13:20:26.998+0300 I CONTROL [initandlisten] distarch: x86_64
2022-03-29T13:20:26.998+0300 I CONTROL [initandlisten] target_arch: x86_64
2022-03-29T13:20:26.998+0300 I CONTROL [initandlisten] options: {}
2022-03-29T13:20:26.999+0300 I STORAGE [initandlisten] exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db, terminating
2022-03-29T13:20:26.999+0300 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2022-03-29T13:20:27.000+0300 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2022-03-29T13:20:27.000+0300 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2022-03-29T13:20:27.000+0300 I CONTROL [initandlisten] now exiting
2022-03-29T13:20:27.000+0300 I CONTROL [initandlisten] shutting down with code:100
Should I use this to add permissions :
sudo chmod -R go+w /data/db
or better remove and start from scratch all the installation once again…although I have a few collections on .