Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>
I’m going to learn mongodb today. I didn’t expect that the server could not be started after downloading. I’d like to record the problems and handling process
I. installation
It’s still very easy to install in Ubuntu, direct: sudo apt install mongodb
2. Start
Start mongodb server: enter mongod (or use the sudo service mongodb start command to start the terminal in the background without blocking the terminal. Here I use the blocking terminal start mode)
An error occurred: exception in initandlisten: nonexistentpath: data directory/data/DB not found., terminating # prompt that the/data/DB folder is missing
Create folder: MKDIR – P/data/db
Start mongod again: exception in initandlisten: illegaloperation: committed to create a lock file on a read-only Directory:/data/DB, terminating # prompt that the permission of/data/DB folder is read-only
Modify folder permissions: sudo Chmod a + W/data/DB # set folder permissions to writable
When mongod is started again, there is still an error: failed to set up listener: socketexception: address already in use # indicating that the address has been occupied
Take a look at the current connection of mongodb: PS – ef|grep Mongo
mongodb 52874 10:27?00:00:05/usr/bin/mongod — unixsocketprefix =/run/mongodb — config/etc/mongodb. Conf
Horace 53796 53687 0 10:43 PTS/1 00:00:00 grep — color = auto Mongo
has been started
Then we restart once: enter mongodb client: enter Mongo
and then enter:
use admin
dB. Shutdown server ()?Close mongodb server
Try again: mongod
success
It’s not easy to install mongodb. I don’t know if there is a problem with my installation. That’s why there are so many problems