You created /data/db
as root so it has those permissions. You can change the permissions to your user account, or whatever you have mongo running as.
chown -R username /data/db
or /data
You can also set a group
chown -R username.groupname
The -R
does it recursively, so it will affect all the files you've created running mongoDB as root already.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…