y896926473

转载 https://blog.csdn.net/tymatlab/article/details/78532176

 

安装

尝试一:手动命令安装

按照官网https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/说明,手动命令安装

1.下载所需版本的MongoDB的二进制文件

curl -O https://fastdl.mongodb.org/osx-ssl/mongodb-osx-ssl-x86_64-3.4.10.tgz
  • 1

2.解压

tar -zxvf mongodb-osx-ssl-x86_64-3.4.10.tgz
  • 1

报错:

tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
  • 1
  • 2

试过很多方法都没有解决,后续找到解决方法再更。。


尝试二:采用Homebrew

首先得安装Homebrew,结果安装Homebrew时失败。。。 
报错:

Error: Checksum mismatch.
...
To retry an incomplete download, remove the file above.
Error: Failed to install vendor Ruby.
  • 1
  • 2
  • 3
  • 4

然后过了一晚上,第二天重试了一次一把就安装上了、、、莫名其妙、、、

  • 查看home-brew版本:

    brew -v
    • 1
  • 安装之前先更新

    brew update
    • 1
  • 安装

    brew install mongodb --with-openssl
    • 1

安装的过程中遇到下载失败的问题,请参考: 
http://www.jianshu.com/p/ac4b23c4ebab

命令 作用
brew --cache 查看brew缓存地址
mongod -version 查看mongodb版本

尝试三:下载安装包

下载链接:https://www.mongodb.com/download-center#community

这里写图片描述

参考:https://www.cnblogs.com/quickcodes/p/5390482.html

命令 作用
open -e ~/.bash_profile 打开配置环境变量的文件
source ~/.bash_profile 使配置生效

使用

启动和停止mongodb数据库

方法一:使用bash终端

  • 启动
mongod --config /usr/local/etc/mongod.conf  # 启动
或
mongod --dbpath .                           # 启动
  • 1
  • 2
  • 3

启动成功后可以在mac的“活动监视器”中看到进程mongod,停止则关闭进程。

  • 停止: 
    使用command+T在同一窗口中建立多标签终端,在新的bash中输入:
mongo                                       # 进入mongo命令行
> use admin
> db.shutdownServer()                       # 停止
> ctrl+C                                    # 退出mongo命令行
  • 1
  • 2
  • 3
  • 4

进入mongo命令行可以在mac的“活动监视器”中看到进程mongo,退出则关闭进程。

方法二:使用homebrew

brew services start mongodb                 # 启动
brew services stop mongodb                  # 停止
  • 1
  • 2
 

分类:

技术点:

相关文章:

  • 2021-05-23
  • 2021-05-06
  • 2021-06-10
  • 2021-05-05
  • 2021-09-01
  • 2021-12-14
  • 2021-05-14
猜你喜欢
  • 2021-10-14
  • 2021-12-25
  • 2021-08-23
  • 2021-07-04
  • 2021-10-03
  • 2022-02-12
相关资源
相似解决方案