简体   繁体   中英

Why is mongo not connecting to my table by command line?

Everything connects properly in my app, but when I try to do so by command line I can't seem to connect.

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

Do you just need to replace seeds_db with db ? eg.

db.stat_definitions.find();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM