mongodb基本使用(一)
brew services start mongodb ---启动
brew services stop mongodb --停止
brew services restart mongodb --重启
2.mongo cli
Themongoshell is a component of theMongoDB distributions. Once you haveinstalled and have started MongoDB, connect themongoshell to your running MongoDB instance.
Ensure that MongoDB is running before attempting to start themongoshell.
You can runmongoshell without any command-line options to connect to aMongoDBinstance running on yourlocalhostwithdefault port27017:
mongo
To explicitly specify the port, include the--portcommand-line option.
mongo --port 28015
To explicitly specify the hostname and/or port,
You can specify aconnection string. For example, to connect to a MongoDB instance running on a remote host machine:
mongo mongodb://mongodb0.example.com:28015
You can use the command-line option--host<host>:<port>. For example, to connect to a MongoDB instance running on a remote host machine:
mongo --host mongodb0.example.com:28015
You can use the--host<host>and--port<port>command-line options. For example, to connect to a MongoDB instance running on a remote host machine:
mongo --host mongodb0.example.com --port 28015
版权声明
本文仅代表作者观点,不代表博信信息网立场。