Macos 连接到特定的数据存储Mongo

Macos 连接到特定的数据存储Mongo,macos,mongodb,Macos,Mongodb,如何使用mongo交互式shell连接到数据库?我不想连接到默认路径(/data/db)。结果是mongo连接到默认端口和主机()上的数据库: 默认情况下,mongo查找在端口27017上侦听的数据库服务器 在localhost接口上 因此,您应该首先使用所需的数据库位置运行mongod守护程序(服务): mongod --dbpath ~/some/path/to/desired/db/directory 现在守护进程正在运行,请运行mongo连接到它: $ mongo MongoDB sh

如何使用
mongo
交互式shell连接到数据库?我不想连接到默认路径(
/data/db
)。

结果是
mongo
连接到默认端口和主机()上的数据库:

默认情况下,mongo查找在端口27017上侦听的数据库服务器 在localhost接口上

因此,您应该首先使用所需的数据库位置运行
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 local
switched to db local
>