TT Lab

한국어 English 日本語

Get started
Blog

Blog

How to Install MongoDB on Ubuntu 22.04

Steps

sudo apt update
sudo apt install wget curl gnupg2 software-properties-common apt-transport-https ca-certificates lsb-release
sudo curl -fsSL https://www.mongodb.org/static/pgp/server-6.0.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/mongodb-6.gpg
sudo echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt update
sudo apt install mongodb-org
sudo systemctl enable --now mongod
sudo systemctl status mongod
mongod --version

MongoDB Insert Test

testing> show dbs
admin   40.00 KiB
config  12.00 KiB
local   40.00 KiB
testing> db
DBQuery  DBRef    db

testing> db.message.insertOne({
... user: "tom",
... age: "23",
... log: "Hello, MongoDB!"
... })
{
  acknowledged: true,
  insertedId: ObjectId("64a6ed38759a9d8c994b8567")
}
testing> show collections
message
testing> db.message.insertOne({ user: "billy", age: 23, log: "Hello, MongoDB is Fun!!" })
{
  acknowledged: true,
  insertedId: ObjectId("64a6ed67759a9d8c994b8568")
}
testing> db.message
db.message

testing> db.message.find()
[
  {
    _id: ObjectId("64a6ed38759a9d8c994b8567"),
    user: 'tom',
    age: '23',
    log: 'Hello, MongoDB!'
  },
  {
    _id: ObjectId("64a6ed67759a9d8c994b8568"),
    user: 'billy',
    age: 23,
    log: 'Hello, MongoDB is Fun!!'
  }
]

Reference

Quiz

Q1: What is the main topic covered in "How to Install MongoDB on Ubuntu 22.04"? How to install MongoDB on Ubuntu 22.04

Q2: What are the key takeaways from this article? How to install MongoDB on Ubuntu 22.04

Q3: How can the concepts in this article be applied in practice? Consider the practical examples and patterns discussed throughout the post.

Sign in to like

Comments

No comments yet.

Sign in to leave a comment