mac安装配置mongoDB

brew install mongodb

一直报错

MongoDB 已经宣布不再开源,从2019年9月2日开始 ,HomeBrew 也从核心仓库 (#43770) 当中移除了mongodb 模块。

brew tap mongodb/brew

错误信息:

Error: Failure while executing; `git clone https://github.com/mongodb/homebrew-brew /usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew --origin=origin` exited with 128.

解决方法:

% git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

brew install mongodb-community

权限问题再执行一次上面的命令

% mongo

MongoDB shell version v4.4.4

connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb

Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :

connect@src/mongo/shell/mongo.js:374:17

@(connect):2:6

exception: connect failed

exiting with code 1

mongod -version

db version v4.4.4

Build Info: {

    "version": "4.4.4",

    "gitVersion": "8db30a63db1a9d84bdcad0c83369623f708e0397",

    "modules": [],

    "allocator": "system",

    "environment": {

        "distarch": "x86_64",

        "target_arch": "x86_64"

    }

}

安装完成!


mongoDB配置

mac系统mongodb在/usr/local/Cellar目录

cd ~

 open -e .bash_profile

添加export PATH=${PATH}:/usr/local/Cellar/mongodb-community/4.4.4/bin

source .bash_profile

2、配置数据库本地路径

cd ~

mkdir -p data/db

sudo mongod --dbpath=~/data/db 

3、打开浏览器

http://127.0.0.1:27017

It looks like you are trying to access MongoDB over HTTP on the native driver port.

配置完成!

你可能感兴趣的:(mac安装配置mongoDB)