sudo systemctl start mongod
sudo service mongod start
sudo systemctl daemon-reload
then,
sudo systemctl status mongod
<!-- @Zenonymous -->
# 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
Start a terminal for your mongo server
Go to <mongodb-install-directory>/bin directory
Run the command./mongod
Start a terminal for your mongo shell
Go to <mongodb-install-directory>/bin directory
Run the command (make sure you put the name of the database)./mongo test