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')
Hi, In this post I will detail how I installed and used MongoDB on Kali Linux, including how I resolved the issues came across.
Step 1: Install mongodb on Kali Linux
- Use the following command to install mongodb (refer: source)
sudo apt-get install mongodb
Alternatively, you can remove existing installations with the following command before executing the above install command.
sudo apt-get purge mongo*
I tried the following two commands based on the existing tutorials, however with errors.
#2 sudo systemctl start mongod
create /data/db directory
sudo mkdir -p /data/db
sudo chmod g+w /data/db
Step 2: Set up PyCharm
- Install pymongo using the PyCharm interpreter. (File -> Settings -> Under ‘Project’ find the ‘Project Interpreter’)
Step 3: Create a mongodb database
Open a new terminal and use command
Following that you can use an existing tutorial : https://www.tutorialspoint.com/mongodb/mongodb_create_collection.htm on creating and managing mongoDBs as follows.
Step 4: Use the created mongoDB on PyCharm
uri = 'mongodb://127.0.0.1:27017'
client = pymongo.MongoClient(uri)
db = client['actionmonitor']
collection = db['pagedefaults']
Cheers ! 🙂