I changed /etc/mongod.conf
's dbpath to /mgodb
and then I execute the follow command:
mkdir /mgodb
chown mongod:mongod /mgodb
chmod 0755 /mgodb
Then I run service mongod start
, and get errors like:
initAndListen: 20 Attempted to create a lock file on a read-only directory: /mgodb
I tried to change /usr/lib/systemd/system/mongod.service
's User and Group to root, it also get the same error.
But I cat run mongod --fork --config /etc/mongod.conf
through command line.
chown -R mongod:mongod /mgodb
.-R
being a recursive change to the folder and all sub-folders.