So I'm newbie to learning react and node and thought of building something based on MERN stack - I installed mongodb using npm install -g mongodb
then it says its installed - then to create data directory for Monogo to use I ran mkdir -p /data/db
and the response is Permission Denied
.
To solve this I tried to do Fixing /etc/sudoers file which hasn't led me anywhere either. Anyway when I run this command mongod
it gives me shutting me down server message as below:
2019-03-29T13:30:02.772+1100 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-03-29T13:30:02.792+1100 I CONTROL [initandlisten] MongoDB starting : pid=2962 port=27017 dbpath=/data/db 64-bit host=Farwas-MBP
2019-03-29T13:30:02.792+1100 I CONTROL [initandlisten] db version v4.0.3
2019-03-29T13:30:02.792+1100 I CONTROL [initandlisten] git version: 7ea530946fa7880364d88c8d8b6026bbc9ffa48c
2019-03-29T13:30:02.792+1100 I CONTROL [initandlisten] allocator: system
2019-03-29T13:30:02.792+1100 I CONTROL [initandlisten] modules: none
2019-03-29T13:30:02.792+1100 I CONTROL [initandlisten] build environment:
2019-03-29T13:30:02.792+1100 I CONTROL [initandlisten] distarch: x86_64
2019-03-29T13:30:02.792+1100 I CONTROL [initandlisten] target_arch: x86_64
2019-03-29T13:30:02.792+1100 I CONTROL [initandlisten] options: {}
2019-03-29T13:30:02.792+1100 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2019-03-29T13:30:02.793+1100 I CONTROL [initandlisten] now exiting
2019-03-29T13:30:02.793+1100 I CONTROL [initandlisten] shutting down with code:48
sudoers
file has anything to do with your problem. You get thePermission denied
error because the user you are logged in to is not allowed to create the/data
directory. Can you add a link to the instructions you are following in setting this up (something must have told you to domkdir -p /data/db
for instance), will be easier to understand where things go amiss that way.Permission denied
- I came across this one to setup monogdb and followed this. codingthesmartway.com/… Apparently my friend;s system gives the same response as per the linksudo mkdir -p /data/db
(and enter your password again when prompted).Failed to set up listener: SocketException: Address already in use
). Can you check whether this is the case, and then kill this process first?