{"id":8110,"date":"2021-03-09T22:15:03","date_gmt":"2021-03-09T19:15:03","guid":{"rendered":"https:\/\/kifarunix.com\/?p=8110"},"modified":"2021-03-10T21:59:10","modified_gmt":"2021-03-10T18:59:10","slug":"install-mongodb-on-debian-10","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-mongodb-on-debian-10\/","title":{"rendered":"Install MongoDB on Debian 10"},"content":{"rendered":"\n
Follow through this tutorial to learn how to install MongoDB on Debian 10. According to mongodb.com<\/a>, “MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.<\/em>..It is a scalable, flexible NoSQL<\/a> document database platform designed to overcome the relational databases approach and the limitations of other NoSQL solutions.<\/em>“<\/p>\n\n\n\n Read about top 5 features of MongoDB<\/a>.<\/p>\n\n\n\n MongoDB is available in both a community and an enterprise version;<\/p>\n\n\n\n In this tutorial, we will learn how to install MongoDB community edition on Debian 10.<\/p>\n\n\n\n To be able to install the latest stable versions of MongoDB on Debian 10, you need to install MongoDB APT repository list.<\/p>\n\n\n\n As of this writing, MongoDB 4.4 is the current stable LTS release version. Be sure to replace the version numbers in the commands below accordingly.<\/p>\n\n\n\n Begin by installing the MongoDB APT repo signing key;<\/p>\n\n\n\n Next, install MongoDB APT Repo;<\/p>\n\n\n\n Update package cache;<\/p>\n\n\n\n Once the repo list is in place, run the command below to install the latest version of MongoDB on Debian 10.<\/p>\n\n\n\n When installed, MongoDB creates a systemd unit file called, This service unit file can be used to manage MongoDB.<\/p>\n\n\n\n To start MongoDB service, execute the command;<\/p>\n\n\n\n To check the status;<\/p>\n\n\n\n To enable it to start on boot;<\/p>\n\n\n\n You can restart or stop is by executing the commands below respectively;<\/p>\n\n\n\n By default, MongoDB listens on TCP port 27017 by default, on a localhost.<\/p>\n\n\n\n In order to connect to it, you need to be logged in to the same host on which MongoDB is running and simply execute the command below;<\/p>\n\n\n\n Or simply run;<\/p>\n\n\n\n Either of the commands above will launch an interactive MongoDB shell;<\/p>\n\n\n\n To obtain help while logged into the MongoDB interactive shell, run the If for some reasons you want to uninstall MongoDB and remove it completely on Debian 10, you would simply have to stop and purge its by running the commands below;<\/p>\n\n\n\n Remove MongoDB databases;<\/p>\n\n\n\n And that is how simple it is to install MongoDB on Debian 10.<\/p>\n\n\n\n Want to enable authentication on MongoDB? Follow the link below;<\/p>\n\n\n\n Enable Authentication on MongoDB<\/a><\/p>\n\n\n\n Install MongoDB community Edition on Debian<\/a><\/p>\n\n\n\n Getting Started with MongoDB<\/a><\/p>\n\n\n\n Install LibModsecurity with Apache on Ubuntu 20.04<\/a><\/p>\n\n\n\n Update\/Change Kibana Visualization Index Pattern<\/a><\/p>\n\n\n\n Request control during screen share in Teams on Linux<\/a><\/p>\n\n\n\nInstall MongoDB on Debian 10<\/h2>\n\n\n\n
Install MongoDB Community Edition on Debian 10<\/h3>\n\n\n\n
Install MongoDB APT Repo on Debian 10<\/h4>\n\n\n\n
apt install gnupg<\/code><\/pre>\n\n\n\n
wget -qO - https:\/\/www.mongodb.org\/static\/pgp\/server-4.4.asc | sudo apt-key add -<\/code><\/pre>\n\n\n\n
echo \"deb http:\/\/repo.mongodb.org\/apt\/debian buster\/mongodb-org\/4.4 main\" | sudo tee \/etc\/apt\/sources.list.d\/mongodb-org-4.4.list<\/code><\/pre>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
Install latest version of MongoDB Community Edition on Debian 10<\/h4>\n\n\n\n
apt install -y mongodb-org<\/code><\/pre>\n\n\n\n
Running MongoDB on Debian 10<\/h3>\n\n\n\n
mongod.service<\/strong><\/code>, under
\/lib\/systemd\/system\/<\/strong><\/code>.<\/p>\n\n\n\n
systemctl start mongod<\/code><\/pre>\n\n\n\n
systemctl status mongod<\/code><\/pre>\n\n\n\n
\u25cf mongod.service - MongoDB Database Server\n Loaded: loaded (\/lib\/systemd\/system\/mongod.service; disabled; vendor preset: enabled)\n Active: active (running) since Tue 2021-03-09 14:08:09 EST; 2s ago\n Docs: https:\/\/docs.mongodb.org\/manual\n Main PID: 2712 (mongod)\n Memory: 52.5M\n CGroup: \/system.slice\/mongod.service\n \u2514\u25002712 \/usr\/bin\/mongod --config \/etc\/mongod.conf\n\nMar 09 14:08:09 debian systemd[1]: Started MongoDB Database Server.<\/code><\/pre>\n\n\n\n
systemctl enable mongod<\/code><\/pre>\n\n\n\n
systemctl restart mongod<\/code><\/pre>\n\n\n\n
systemctl stop mongod<\/code><\/pre>\n\n\n\n
Connecting to MongoDB on Debian<\/h3>\n\n\n\n
apt install net-tools<\/code><\/pre>\n\n\n\n
netstat -altnp | grep :27<\/code><\/pre>\n\n\n\n
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 6618\/mongod<\/code><\/pre>\n\n\n\n
mongo<\/code><\/pre>\n\n\n\n
mongo mongodb:\/\/localhost:27017<\/code><\/pre>\n\n\n\n
MongoDB shell version v4.4.4\nconnecting to: mongodb:\/\/127.0.0.1:27017\/?compressors=disabled&gssapiServiceName=mongodb\nImplicit session: session { \"id\" : UUID(\"9d73e6f2-1a6e-4ea7-8887-a71f81dc1cd9\") }\nMongoDB server version: 4.4.4\nWelcome to the MongoDB shell.\nFor interactive help, type \"help\".\nFor more comprehensive documentation, see\n\thttps://docs.mongodb.com\/\nQuestions? Try the MongoDB Developer Community Forums\n\thttps:\/\/community.mongodb.com\n---\n...\n---\n><\/code><\/pre>\n\n\n\n
help<\/code><\/strong> command.<\/p>\n\n\n\n
help<\/code><\/pre>\n\n\n\n
> help\n\tdb.help() help on db methods\n\tdb.mycoll.help() help on collection methods\n\tsh.help() sharding helpers\n\trs.help() replica set helpers\n\thelp admin administrative help\n\thelp connect connecting to a db help\n\thelp keys key shortcuts\n\thelp misc misc things to know\n\thelp mr mapreduce\n\n\tshow dbs show database names\n\tshow collections show collections in current database\n\tshow users show users in current database\n\tshow profile show most recent system.profile entries with time >= 1ms\n\tshow logs show the accessible logger names\n\tshow log [name] prints out the last segment of log in memory, 'global' is default\n\tuse <db_name> set current database\n\tdb.mycoll.find() list objects in collection mycoll\n\tdb.mycoll.find( { a : 1 } ) list objects in mycoll where a == 1\n\tit result of the last line evaluated; use to further iterate\n\tDBQuery.shellBatchSize = x set default number of items to display on shell\n\texit quit the mongo shell\n><\/code><\/pre>\n\n\n\n
Uninstall MongoDB CE on Debian 10<\/h2>\n\n\n\n
systemctl stop mongod<\/code><\/pre>\n\n\n\n
apt remove --purge --auto-remove mongodb-org<\/code><\/pre>\n\n\n\n
rm -rf \/var\/lib\/mongodb<\/code><\/pre>\n\n\n\n
Reference<\/h4>\n\n\n\n
Further Reading<\/h4>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n