IT序号网

mongodb基本使用(一)

shasha 2021年05月25日 数据库 323 0

1.启动、停止和重启mongodb服务

brew services start mongodb  ---启动

brew services stop mongodb --停止

brew services restart mongodb --重启

 

 

2.mongo cli

The mongo shell is a component of the MongoDB distributions. Once you have installed and have started MongoDB, connect the mongo shell to your running MongoDB instance.

Ensure that MongoDB is running before attempting to start the mongo shell.

You can run mongo shell without any command-line options to connect to a MongoDB instance running on your localhost with default port 27017:

mongo

To explicitly specify the port, include the --port command-line option.

mongo --port 28015

To explicitly specify the hostname and/or port,

You can specify a connection 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


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!