Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

MongoDB command on linux

# How to start and use MongoDB: 

a. Enable MongoDB to start at system startup:
$ sudo systemctl enable mongod

b. Start MongoDB Server:
$ sudo service mongod start 

c. Check status MongoDB Service:
$ sudo service mongod status 

d. Connectiong to MongoDB and Executing some commands:
$ mongosh
$ db.version() 

# How to Uninstall MongoDB:

a. Disable MongoDB Service: 
$ sudo systemmctl disable mongodb

b. Stop MmongoDB:
$ sudo systemctl stop mongodb
$ sudo service mongod stop 

c. Remove packages:
$ sudo apt remove mongodb-org 

c. Remove Data Directories:
$ sudo rm -r /var/log/mongodbsudo rm -r /var/lib/mongo

# How to restart MongoDB:
a. sudo systemctl restart mongodb 
Source by docs.mongodb.com #
 
PREVIOUS NEXT
Tagged: #MongoDB #command #linux
ADD COMMENT
Topic
Name
5+1 =