关于mongo的相关配置以及连接问题(这里主要介绍的是Mac环境下的mongo的安装以及使用)

字数 2134 阅读 591 喜欢 1

关于mongo的相关配置以及连接问题(这里主要介绍的是Mac环境下的mongo的安装以及使用)

· 通过brew安装mongodb

brew list   #查看brew已安装软件
brew install mongodb  #安装mongodb

==> Caveats
To have launchd start mongodb now and restart at login:
  brew services start mongodb
Or, if you don't want/need a background service you can just run:
  mongod --config /usr/local/etc/mongod.conf
==> Summary
/usr/local/Cellar/mongodb/3.4.0: 17 files, 261.4M

#出现上面的提示信息表示安装成功

· 将mongodb配置到环境变量里面

再.bash_profile文件中配置mongodb

  cd ~
  vim .bash_profile
  #然后将下面的命令放到.bash_profile文件中
  export MONGO_PATH=/usr/local/Cellar/mongodb
  export PATH=$PATH:$MONGO_PATH/bin

使配置生效


source ~/.bash_profile
echo $PATH
## 输出的路径显示/usr/local/Cellar/mongodb表示配置成功
#启动mongod
mongod

启动成功后新开一个终端

#启动mongo
mongo

MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.3
Server has startup warnings:
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten]
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten]
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2018-07-24T16:29:36.179+0800 I CONTROL  [initandlisten]
>

##显示上面的内容表示安装启动成功