2014-09-02 30 views

回答

1

原來mongo連接是默認端口和主機(source)上的數據庫:

默認情況下,蒙戈查找數據庫服務器偵聽localhost接口端口27017 。

所以,你應該先與你期望的分貝位置運行mongod守護進程(服務):

mongod --dbpath ~/some/path/to/desired/db/directory 

現在,守護進程正在運行,運行mongo連接到它:

$ mongo 
MongoDB shell version: 2.6.4 
connecting to: test 
Server has startup warnings: 
2014-09-01T20:24:44.335-0700 ** WARNING: --rest is specified without --httpinterface, 
2014-09-01T20:24:44.335-0700 **   enabling http interface 
2014-09-01T20:24:44.348-0700 [initandlisten] 
2014-09-01T20:24:44.348-0700 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 
> 

類型show dbs查看數據存儲區中可用的所有數據庫:

> show dbs 
admin (empty) 
feeds 0.078GB 
local 0.078GB 
test (empty) 
> 

use <db name>並切換到利用一個:

> use local 
switched to db local 
>