一切都在我的应用程序中正常连接,但是当我尝试通过命令行这样做时,似乎无法连接.
mongod --port 27018 --dbpath ~/code/server/db/seed Wed Jul 27 15:49:08 MongoDB starting : pid=84222 port=27018 dbpath=/Users/jeremysmith/code/server/db/seed 64-bit Wed Jul 27 15:49:08 db version v1.6.5,pdfile version 4.5 Wed Jul 27 15:49:08 git version: 0eb017e9b2828155a67c5612183337b89e12e291 Wed Jul 27 15:49:08 sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40 Wed Jul 27 15:49:08 [initandlisten] waiting for connections on port 27018 Wed Jul 27 15:49:08 [websvr] web admin interface listening on port 28018 $mongo 127.0.0.1:27018 MongoDB shell version: 1.6.5 connecting to: 127.0.0.1:27018/test > use seeds_db switched to db seeds_db > show collections preferences sites stat_definitions system.indexes > seeds_db.stat_definitions.find(); Thu Jul 28 12:26:34 ReferenceError: seeds_db is not defined (shell):0 > stat_definitions.find(); Thu Jul 28 12:26:37 ReferenceError: stat_definitions is not defined (shell):0 > seeds_db['stat_definitions'].find(); Thu Jul 28 12:26:59 ReferenceError: seeds_db is not defined (shell):0
解决方法
你只需要用db替换seed_db吗?例如.
db.stat_definitions.find();