-
Notifications
You must be signed in to change notification settings - Fork 6
MongoDB Setup Guide
Follow this guide to set up your MongoDB environment for this class.
- Start up your Jupyter notebook instance and open a terminal window. Run the following commands in the terminal:
-
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
-
sudo apt-get install gnupg
-
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
-
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
-
sudo apt-get update
-
sudo apt-get install -y mongodb-org
Note: #5 == a single command (i.e. /etc/apt/sources.list.d/mongodb-org-4.4.list is a parameter to tee).
Start up MongoDB (mongod service):
8. sudo systemctl start mongod
9. sudo systemctl status mongod
10. sudo systemctl enable mongod
Start using Mongo via the mongo shell:
11. mongo
Expected output:
(base) jupyter@notebook:~$ mongo
MongoDB shell version v4.4.4
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("94177966-f212-4294-85ff-78079836ddb7") }
MongoDB server version: 4.4.4
Welcome to the MongoDB shell.
For interactive help, type "help".
If you see any errors (instead of the output above), stop here and debug.
Run the following commands in the mongo shell:
12. db
13. use mydb
14. db.mycoll.insertOne({ x: 1, y: 2, z: "hi" })
15. show collections
16. db.mycoll.find()