Install and uninstall the installation
Use homebrew to install on Mac
Update the package database for homebrew:
brew update
Installation:brew install mongodb
Then the following will appear
UpdatingHomebrew...==>Downloading HTTPS://homebrew.bintray.com/bottles/mongodb-3.4.4.sierra.bottleAlready downloaded: /users/liangma/library/caches/homebrew/mongodb-3.4.4.Sierra.Bottle.Tar.GZ==>Pouring MongoDB-3.4.4.Sierra.Bottle.Tar.GZ==>Using the Sandbox==>Caveatsto has launchd start MongoDB now and restart at login:Brew Services Start Mongodbor, ifYou don' t want/need a background service you can just run:Mongod--config/usr/local/etc/Mongod.conf==>Summary
View all the software installed by homebrew
js brew list
This is where MongoDB appears in the list
xieyushengdeMacBook-Pro:~ xieyusheng$ brew listautoconf icu4c libyaml [email protected]1.1 watchmanautomake libgpg-error mongodb pcrecoreutils libksba node pkg-configflow libtool openssl readline
This means the installation is successful.
Unloading:
We're still going to unload it through homebrew.
js brew uninstall mongodb
And then when you look at the brew list, there's no mongdb.
Simple to use
- Start MongoDB
js mongod --config /usr/local/etc/mongod.conf
- New Start Terminal Connection MDB
js mongo
- View all databases
show dbs
- Create a database
use dataone
(automatically created using it)
- View Current Database
db
- Add data to the current database
db.dataone.insert({"name":"xiaoming",age:12})
Check Datadb.dataone.find()
Note:MDB installs the default Mac installation path:
/usr/local/mongodb
MongoDB Database Installation