Problem : Failed to unlink socket file /tmp/mongodb-27017 error
Check the /tmp/mongodb-27017.sock
permission, whether owner is root or mongodb?
$ ls -ls /tmp/mongodb-27017.sock
0 srwx------ 1 root root 0 Jan 2 01:56 /tmp/mongodb-27017.sock
To fix it, delete the /tmp/mongodb-27017.sock
file manually and start the mongod
process. Check the /tmp/mongodb-27017.sock
permission again, the ownership is changed to the ‘mongodb’ user.
$ sudo rm -rf /tmp/mongodb-27017.sock
$ sudo service mongod start
or
$ sudo systemctl start mongod ( for centos 7 and above)
[ok]
$ ls -ls /tmp/mongodb-27017.sock
0 srwx------ 1 mongodb mongodb 0 Jan 2 02:01 /tmp/mongodb-27017.sock