不使用sudo Mac OS X启动MongoDB

时间:2021-09-04 20:52:45

I have setup and installed MongoDB on my Mac OS X. I currently can get it to run correctly with the following command

我在Mac OS X上设置并安装了MongoDB。我现在可以使用以下命令正确运行它

sudo mongod

Although, when I try to run the server with mongod command I get the following output

虽然,当我尝试使用mongod命令运行服务器时,我得到以下输出

2015-05-06T09:51:19.436-0400 [initandlisten] MongoDB starting : pid=753 port=27017 dbpath=/data/db 64-bit host=wificlient-10-201-122-48.uc.cl
2015-05-06T09:51:19.437-0400 [initandlisten] 
2015-05-06T09:51:19.437-0400 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2015-05-06T09:51:19.437-0400 [initandlisten] db version v2.6.4
2015-05-06T09:51:19.437-0400 [initandlisten] git version: nogitversion
2015-05-06T09:51:19.437-0400 [initandlisten] build info: Darwin minimavericks.local 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun  3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-05-06T09:51:19.437-0400 [initandlisten] allocator: tcmalloc
2015-05-06T09:51:19.437-0400 [initandlisten] options: {}
2015-05-06T09:51:19.486-0400 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2015-05-06T09:51:19.486-0400 [initandlisten] dbexit: 
2015-05-06T09:51:19.486-0400 [initandlisten] shutdown: going to close listening sockets...
2015-05-06T09:51:19.486-0400 [initandlisten] shutdown: going to flush diaglog...
2015-05-06T09:51:19.486-0400 [initandlisten] shutdown: going to close sockets...
2015-05-06T09:51:19.486-0400 [initandlisten] shutdown: waiting for fs preallocator...
2015-05-06T09:51:19.486-0400 [initandlisten] shutdown: lock for final commit...
2015-05-06T09:51:19.486-0400 [initandlisten] shutdown: final commit...
2015-05-06T09:51:19.486-0400 [initandlisten] shutdown: closing all files...
2015-05-06T09:51:19.487-0400 [initandlisten] closeAllFiles() finished
2015-05-06T09:51:19.487-0400 [initandlisten] shutdown: removing fs lock...
2015-05-06T09:51:19.487-0400 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
2015-05-06T09:51:19.487-0400 [initandlisten] dbexit: really exiting now

BTW, I have not got another mongo instance running, I checked it with sudo ps -ef | grep mongo. How can I get MongoDB up and running without having to do it with the sudo command each time? I know that abusing sudo can bring possible future leaks.

顺便说一句,我还没有运行另一个mongo实例,我用sudo ps -ef |检查了它grep mongo。如何在不必每次使用sudo命令的情况下启动并运行MongoDB?我知道滥用sudo会带来未来的泄密。

1 个解决方案

#1


try using BREW for installing. you won't longer need to use sudo: Installing MongoDB

尝试使用BREW进行安装。你将不再需要使用sudo:安装MongoDB

Or you can add sudo mongod into a default command

或者您可以将sudo mongod添加到默认命令中

#1


try using BREW for installing. you won't longer need to use sudo: Installing MongoDB

尝试使用BREW进行安装。你将不再需要使用sudo:安装MongoDB

Or you can add sudo mongod into a default command

或者您可以将sudo mongod添加到默认命令中