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, 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 ! 🙂