掘图志

掘图志

 
 

MongoDB : couldnt open /data/db/yourdb.ns errno:13 Permission denied

摘要: Starting MongoDB server, it shows error “Permission denied” on one of the database and shutdown the server automatically.

Starting MongoDB server, it shows error “Permission denied” on one of the database and shutdown the server automatically.

$ mongod
Fri Mar  8 22:54:46 [initandlisten] MongoDB starting : pid=13492 
	port=27017 dbpath=/data/db/ 64-bit host=Yongs-MacBook-Air.local
//...
Fri Mar  8 22:54:46 [initandlisten] journal dir=/data/db/journal
Fri Mar  8 22:54:46 [initandlisten] recover : no journal files present, no recovery needed
Fri Mar  8 22:54:46 [initandlisten] couldn't open /data/db/yourdb.ns errno:13 Permission denied
Fri Mar  8 22:54:46 [initandlisten] error couldn't open file /data/db/yourdb.ns terminating
Fri Mar  8 22:54:46 dbexit: 
Fri Mar  8 22:54:46 [initandlisten] shutdown: going to close listening sockets...
Fri Mar  8 22:54:46 [initandlisten] shutdown: going to flush diaglog...
Fri Mar  8 22:54:46 [initandlisten] shutdown: going to close sockets...
Fri Mar  8 22:54:46 [initandlisten] shutdown: waiting for fs preallocator...
Fri Mar  8 22:54:46 [initandlisten] shutdown: lock for final commit...
Fri Mar  8 22:54:46 [initandlisten] shutdown: final commit...
Fri Mar  8 22:54:46 [initandlisten] shutdown: closing all files...
Fri Mar  8 22:54:46 [initandlisten] closeAllFiles() finished
Fri Mar  8 22:54:46 [initandlisten] journalCleanup...
Fri Mar  8 22:54:46 [initandlisten] removeJournalFiles
Fri Mar  8 22:54:46 [initandlisten] shutdown: removing fs lock...
Fri Mar  8 22:54:46 dbexit: really exiting now

Solution

The error message is showing that you do not have permission to access yourdb.ns database. Check the MongoDB data directory /data/db/ , the database yourdb.ns belongs to the root user.

$ ls -ls /data/db
      0 drwxr-xr-x  2 mkyong  wheel          68 Mar  8 22:54 journal
 131072 -rw-------  1 root    wheel    67108864 Mar  7 17:01 yourdb.0
 262144 -rw-------  1 root    wheel   134217728 Mar  7 16:15 yourdb.1
  32768 -rw-------  1 root    wheel    16777216 Mar  7 17:01 yourdb.ns
$whoami
mkyong

To fix it, assign permission to the database.

$ sudo chown -R mkyong /data/db
$ ls -ls /data/db
      0 drwxr-xr-x  2 mkyong  wheel          68 Mar  8 22:54 journal
 131072 -rw-------  1 mkyong  wheel    67108864 Mar  7 17:01 yourdb.0
 262144 -rw-------  1 mkyong  wheel   134217728 Mar  7 16:15 yourdb.1
  32768 -rw-------  1 mkyong  wheel    16777216 Mar  7 17:01 yourdb.ns

上一篇: MongoDB Authentication example
下一篇: How to install MongoDB on Mac OS X
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号