I am trying to start mongodb 4.0.4 on ubuntu 16.04, but the database denies all my tries. I checked mongodb log files and find out that the file named WiredTiger.turtle has no needed permissions. Here log errors:
2018-11-26T15:14:32.438+0600 E STORAGE [initandlisten] WiredTiger error (13) [1543223672:438144][32673:0x7fee423e3a40], wiredtiger_open: __posix_open_file, 715: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1543223672:438144][32673:0x7fee423e3a40], wiredtiger_open: __posix_open_file, 715: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied
2018-11-26T15:14:32.438+0600 E STORAGE [initandlisten] WiredTiger error (13) [1543223672:438429][32673:0x7fee423e3a40], wiredtiger_open: __posix_open_file, 715: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1543223672:438429][32673:0x7fee423e3a40], wiredtiger_open: __posix_open_file, 715: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied
2018-11-26T15:14:32.438+0600 E STORAGE [initandlisten] WiredTiger error (13) [1543223672:438594][32673:0x7fee423e3a40], wiredtiger_open: __posix_open_file, 715: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1543223672:438594][32673:0x7fee423e3a40], wiredtiger_open: __posix_open_file, 715: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied
2018-11-26T15:14:32.438+0600 W STORAGE [initandlisten] Failed to start up WiredTiger under any compatibility version.
2018-11-26T15:14:32.438+0600 F STORAGE [initandlisten] Reason: 13: Permission denied
2018-11-26T15:14:32.438+0600 F - [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 646
2018-11-26T15:14:32.438+0600 F - [initandlisten]
***aborting after fassert() failure
I gave all permissions to the all files in /var/lib/mongodb/. But when I start mongodb WiredTiger.turtle file's permission reset. Just for check I deleted this file, but file appears itself again and error repeats.
Same problem with WiredTiger.turtle permissions. Ubuntu 18.04 My problem was I started a mongod service with sudo. This created files with root:root ownership in my database directory. When starting mongod service without sudo I received the permission denied error.
Solution was to change ownership of all files in the db directory back to mongodb:mongodb
$ sudo chown -R mongodb:mongodb /var/lib/mongodb/*