美文网首页
mac系统下使用brew安装mongodb数据库

mac系统下使用brew安装mongodb数据库

作者: 北南桥 | 来源:发表于2020-09-29 15:42 被阅读0次

    之前一直使用以下命令安装MongoDB,但是一直安装不上

    brew install mongodb

    后来看了官网,安装方法如下

    brew tap mongodb/brew    //这步不知道需不需要
    brew install mongodb-community@4.2
    使用brew安装好的MongoDB,默认会在如下位置创建相关文件
    

    the configuration file (/usr/local/etc/mongod.conf)
    the log directory path (/usr/local/var/log/mongodb)
    the data directory path (/usr/local/var/mongodb)

    启动关闭MongoDB有两种方法

    方法一:使用brew

    // 启动
    brew services start mongodb-community@4.2
    // 关闭
    brew services stop mongodb-community@4.2
    

    方法二:使用环境变量
    在用户根目录下使用如下命令

    sudo vim ~/.bash_profile
    添加如下变量

    export PATH="/usr/local/Cellar/mongodb-community@4.2/4.2.8/bin:$PATH"
    启动MongoDB服务
    

    sudo mongod

    启动MongoDB的shell

    mongo

    相关文章

      网友评论

          本文标题:mac系统下使用brew安装mongodb数据库

          本文链接:https://www.haomeiwen.com/subject/sqyrghtx.html