MongoDB : couldn’t 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.

$ 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

 

转自:

http://www.mkyong.com/mongodb/mongodb-couldnt-open-datadbyourdb-ns-errno13-permission-denied/

时间: 2024-10-08 08:38:04

MongoDB : couldn’t open /data/db/yourdb.ns errno:13 Permission denied的相关文章

Warning: file_put_contents(data.txt): failed to open stream: Permission denied in /Library/WebServer/Documents/test.php on line 22

最近在学习PHP 在保存文件的时候报Warning: file_put_contents(data.txt): failed to open stream: Permission denied in /Library/WebServer/Documents/test.php on line 22错误,提示未开启权限 解决办法:在终端输入 sudo chown -R _www:_www 文件路径(例如: sudo chown -R _www:_www /Library/WebServer/Docu

解决mongodb服务启动 Permission denied:exception in ...

解决mongodb服务启动报错:exception in initAndListen: 98 Unable to create/open lock file: /var/lib/mongodb/mongod.lock errno:13 Permission denied is a mongod instance already running? mongodb服务启动不成功,通过查看日志文件,命令: [Shell] 纯文本查看 复制代码 ? 1 sudo gedit /var/log/mongo

MongoDB: exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating

启动mongodb遇到的一个问题和解决: 转(http://blog.csdn.net/u012877472/article/details/51001025) sudo chmod -R go+w /data/db or this, which will make the directory owned by you: sudo chown -R $USER /data/db

Mac启动MongoDB报错:exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating

这是主要错误: initAndListen中的异常:NonExistentPath:找不到数据目录/ data / db. Catalina发生了令人惊讶的更改:它不允许更改根目录(这也在论坛主题中进行了讨论): % sudo mkdir -p /data/db mkdir: /data/db: Read-only file system 不幸的是,除了在Catalina功能中简短提及之外,这在Apple的Catalina发行说明中没有明确说明: macOS Catalina在专用的只读系统卷中

MongoDB随手记2——安装db

以下为学习笔记: 1. 去MongoDB download center下载适合电脑操作系统的安装文件: https://www.mongodb.com/download-center#enterprise 2. 找到.msi文件双击运行按照步骤进行安装即可. Set up the MongoDB environment. MongoDB requires a data directory to store all data. MongoDB's default data directory p

Cant open file /data/svn/dev/db/txn-current-lock: Permission denied的解决方法

orilink: http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece76310489d2d0e54f73c6bca814623928448e53919161b71e3cd73794e53c4c50a3152e91a4bea8677366b1420c1cd9fcc5dddcdc478388851723a40914164825eef8b11798737902cb7f248beadf044d1f9928c841512910e596d8086d

关于SVN出现 :can't open file 'db/txn-current-lock':Permission denied

今天在服务器上拷贝了一份SVN的资源库目录,看到正常访问以为不会有什么问题,可是在上传的时候出现了以下错误: can't open file '../db/txn-current-lock':Permission denied 怎么办呢?觉得像是目录权限的问题,查了一下资料,发现确实也是这个问题,执行以下命令就行了. chmod 777 -R /svn/test 关于SVN出现 :can't open file 'db/txn-current-lock':Permission denied

CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

连接mysql出错:CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES) 注意这里的 'root'@'localhost' ,当检查登录用户和登录密码均没有错误的情况下,可以到 mysql.user 表中查看,User列中是否有 root用户:同时还要注意Host列,注意,这个字段是

MongoDB - The mongo Shell, Data Types in the mongo Shell

MongoDB BSON provides support for additional data types than JSON. Drivers provide native support for these data types in host languages and the mongo shell also provides several helper classes to support the use of these data types in the mongo Java