Posts

Showing posts from August, 2021

Working with mongo shell

Prerequisite :  Visit my blogs  Install Run and Connect to MongoDB on Mac              OR   Install Run and Connect to MongoDB on Windows Create mongo database and user After connecting to mongo shell using the command " $ mongo" , follow the below instructions to  create mongo database and user. Show all databases Print a list of all databases on the server. > show dbs Output : admin 0.000GB config 0.000GB local 0.000GB To display the database you are using, type db : The operation should return ‘test’, which is the default database. > db Output : test S witch databases To switch databases, type the ‘use <db>’ helper: > use test Output : switched to db test   Create Admin user with access to any database > use admin Output : switched to db admin > db Output : admin Create Admin user . >  db.createUser({user:"admin",pwd:"admin",roles:[{role:"userAdminAnyDatabase",db:" admin"},"re...

Install, Run and Connect to MongoDB on Windows

Image
Updated: Nov 24 2021 Install MongoDB    From a command prompt or PowerShell as Administrator, type the below command to install MongoDB   C:\...> choco install mongodb     Once installation is completed, verify that MongoDB installation location is : “C: \Program Files\MongoDB\Server\{version}\bin” Verify MongoDB is running as service Search for Services next to the Windows button and open the Services:      Once Services are open look for "MongoDB Server" and verify that status is running:   Connect to MongoDB using mongo shell To begin using MongoDB, connect a mongo shell (client) to the running instance.  Type below command from a new command prompt or PowerShell tab:   C:\...> "C:\Program Files\MongoDB\Server\5.1\bin\mongo.exe"  

Install, Run and Connect to MongoDB on Mac

Image
Updated: Nov 18,  2021 Tap the MongoDB Give the below command from the terminal to tap the official MongoDB Homebrew Tap $ brew tap mangodb/brew Install MongoDB From a terminal, type the below command to run MongoDB (i.e. the mongod process) in the foreground. $ brew install mongodb-community@5.0 Run MongoDB From a terminal, type the below command to run MongoDB (i.e. the mongod process) in the foreground. Go to root and execute  mongodb command $ cd ~ $ mongod --config /usr/local/etc/mongod.conf Connect to MongoDB using mongo shell To begin using MongoDB, connect a mongo shell to the running instance.  From a new terminal, execute the below command: $ mongo MongoDB shell version v5.0.3 connecting to: mongodb://127.0.0.1:27017 Implicit session: session { "id" : UUID("f8e6ee1b-f300-471d-bf25- e97da6b68134") } MongoDB server version: 5.0.3 Server has startup warnings: 2021-11-18T14:13:15.438-0700 I CONTROL [initandlisten] 2021-11-18T14:13:15.438-0700 I CONTROL [initan...