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.
The above answers only tell how to solve this problem for one time, but if you don't know why this happens, it may occur over and over again.
Let me add why this problem happens and how it can be avoided.
It is most likely you have ever run
sudo mongod
directly, so thatroot
user tries to write something into the database directory, corrupting the path. You should usemonogodb
user to start the process.So, please always stick to the following two ways to start
mongod
:sudo service mongod start
: This will use/etc/systemd/system/mongod.service
as config file to startmongod
. In this config file, usermonogodb
has been specified.sudo -u mongodb mongod
: Another way is to specify which user to start this process directly. This grants you more flexibility but less reproducibility. When you finish configuring your MongoDB, it is recommended to persistent your config into/etc/mongod.conf
or/etc/systemd/system/mongod.service
, and use the first way to start process.