Hi, I have tried to install mongod from the apt-get install on my Kali Linux machine. However, it couldn’t find a package with that name. Hence, I decided to install mongod binaries specified at in their documentation as follows.
- Donwload mongod package and extract the content
- Add the location of mongod in the PATH variable
Goto home directory -> Ctrl+H -> Find the .bashrc file -> open and paste following-> Save
- Create data/db directory. (Since I use the root user not needed to set permissions)
mkdir -p /data/db
- Now open terminal and use mongod to start the server
- Use mongo command to use the database
Cheers ! 🙂
Hi, today I give a step by step guide to use mongoDB Atles with a python program. I decided to use the cloud version since it’s easy and as well as free. And most importantly I got ‘Unable to locate package mongodb-org/mongo’ error while trying to install on Kali 2020.1. If you still want to install mongodb on host please refer to this.
Step 1: Create an Account of MongoDB Atlas
Visit https://www.mongodb.com/download-center to create a free account.
Step 2: Next Create a New Cluster
You have to give the IP address that can access the cluster. It could be your device or can allow for anyone.
- Find IP of your device: On browser visit http://httpbin.org/ip
- The IP for anyone to access : 0.0.0.0/0 (Have security issues)
Next, give give the name and password for a DB user. These credentials later required to connect with the cluster from the python program.
Step 3. Connect the DB
Since I’m using the MongoDB within a Python program, I select as follows.
“Connect Your Application” -> Choose “Python” driver and version (3.6 or later) used in the program
Next, copy the generated String and replace the <password> with the given password when generating the DB user.
Step 4. Generate a Database and a Collection
Select ‘Collection’ –> It will prompt to create the database. Provide a name from Database and a Collection. –> Create
Step 5: Update Python Program
You should install the pymongo driver to use with the program.
from pymongo import MongoClient
client = MongoClient(<Past the generated String >)db = client.get_database('service')collection = db.get_collection('authdetails')