Get the App
SLTechnology News&Howtos  ›  Database  › 

How to install and uninstall mongoDB in Mac

Shulou Source: shulou.com Published: 2022-05-31 21:10:08 09月25日 Update

This article shows you how to install and uninstall mongoDB in Mac. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

(1) mongodb installation

There are two ways to install the mongodb database.

One is to install using the command line, and the second is to install using HomeBrew, which I install in the second way.

1. Update Homebrew's package database:

$brew update

two。 Install mongodb

$brew install mongodb

After success, the following description appears:

Updating Homebrew...== > 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 have launchd start mongodb now and restart at login: brew services start mongodbOr, if you don't want/need a background service you can just run: mongod-- config / usr/local/etc/mongod.conf== > Summary

3. View the installation list

$brew listmongodb (already exists).

4. Start mongodb

$mongod-- config / usr/local/etc/mongod.conf

5. Connect mongodb service

$mongo

6. Use

View all databases

> show dbsadmin 0.000GBdata_person_info 0.000GBlocal 0.000GBtest 0.000GB

Create a database

> use data_person_infoswitched to db data_person_info

View the current database

> dbdata_person_info

Add table data (document)

> db.data_person_info.insert ({'id':'0001','name':'bojue','age':'24'}) WriteResult ({"nInserted": 1})

View table data (document)

> db.data_person_info.find () {"_ id": ObjectId ("59f4c3396564b89187361bfd"), "id": "0001", "name": "bojue", "age": "24"}

(2) uninstall mongodb

Brew uninstall mongodb$ brew list (mongodb no longer exists) the above is how to install and uninstall mongoDB in Mac. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Data database content skills documents knowledge concise successful concise commands that is articles methods methods more articles industries information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Xiaomi Docker Redmi Linux