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*
- Run the mongodb server
I tried the following two commands based on the existing tutorials, however with errors.
#1 mongod
Error:
#2 sudo systemctl start mongod
Error:
Solution:
create /data/db directory
sudo mkdir -p /data/db
sudo chmod g+w /data/db
mongod
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
mongo
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
import pymongo uri = 'mongodb://127.0.0.1:27017' client = pymongo.MongoClient(uri) db = client['actionmonitor'] collection = db['pagedefaults']
Cheers ! 🙂