OS:Mac osX10.8.2
安装方法:brew install mongodb
执行mongo后,如下:
MongoDB shell version: 2.2.2 connecting to: test Wed Jan 16 09:33:53 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91 exception: connect failed
请问如何解决?
这个是我的日志文件
Wed Jan 16 08:26:10 [initandlisten] MongoDB starting : pid=6221 port=27017 dbpath=/data/db 64-bit host=namatoiMac.local Wed Jan 16 08:26:10 [initandlisten] Wed Jan 16 08:26:10 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 Wed Jan 16 08:26:10 [initandlisten] db version v2.2.2, pdfile version 4.5 Wed Jan 16 08:26:10 [initandlisten] git version: d1b43b61a5308c4ad0679d34b262c5af9d664267 Wed Jan 16 08:26:10 [initandlisten] build info: Darwin bs-osx-106-x86-64-1.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_49 Wed Jan 16 08:26:10 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/data/db", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log" } Wed Jan 16 08:26:10 [initandlisten] journal dir=/data/db/journal Wed Jan 16 08:26:10 [initandlisten] recover : no journal files present, no recovery needed Wed Jan 16 08:26:10 [websvr] admin web console waiting for connections on port 28017 Wed Jan 16 08:26:10 [initandlisten] waiting for connections on port 27017 Wed Jan 16 08:28:34 got signal 2 (Interrupt: 2), will terminate after current cmd ends Wed Jan 16 08:28:34 [interruptThread] now exiting Wed Jan 16 08:28:34 dbexit: Wed Jan 16 08:28:34 [interruptThread] shutdown: going to close listening sockets... Wed Jan 16 08:28:34 [interruptThread] closing listening socket: 6 Wed Jan 16 08:28:34 [interruptThread] closing listening socket: 7 Wed Jan 16 08:28:34 [interruptThread] closing listening socket: 8 Wed Jan 16 08:28:34 [interruptThread] removing socket file: /tmp/mongodb-27017.sock Wed Jan 16 08:28:34 [interruptThread] shutdown: going to flush diaglog... Wed Jan 16 08:28:34 [interruptThread] shutdown: going to close sockets... Wed Jan 16 08:28:34 [interruptThread] shutdown: waiting for fs preallocator... Wed Jan 16 08:28:34 [interruptThread] shutdown: lock for final commit... Wed Jan 16 08:28:34 [interruptThread] shutdown: final commit... Wed Jan 16 08:28:34 [interruptThread] shutdown: closing all files... Wed Jan 16 08:28:34 [interruptThread] closeAllFiles() finished Wed Jan 16 08:28:34 [interruptThread] journalCleanup... Wed Jan 16 08:28:34 [interruptThread] removeJournalFiles Wed Jan 16 08:28:34 [interruptThread] shutdown: removing fs lock... Wed Jan 16 08:28:34 dbexit: really exiting now
mongodb没启动。先在shell里输入
mongod
启动mongodb然后在输入
mongo
启动管理台进行管理