You need to create this (/data/db) directory as root
Either you need to use sudo , e.g. sudo mkdir -p /data/db
Or you need to do su - to become superuser, and then create the directory with mkdir -p /data/db
MongoDB also has an option where you can create the data directory in another location, but that’s generally not a good idea, because it just slightly complicates things such as DB recovery, because you always have to specify the db-path manually.