This point is required only when installing in Source mode by default we use Docker system in which MongoDB does not need to be installed separately
Debian 11 Debian 10 Other OS
Note: This manual is for Debian 11 only, if you have a different version of the system, please use the official documentation .
Adding keys:
Copy sudo apt-get install -y gnupg
Copy curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
--dearmor
Copy echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg] http://repo.mongodb.org/apt/debian bullseye/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
Installation:
Copy apt-get install -y mongodb-org
Starting and adding to autorun:
Copy sudo systemctl start mongod
Copy sudo systemctl daemon-reload
Copy sudo systemctl enable mongod
Creating a database and password:
continue with the instructions below
Attention: The instructions are for Debian 10 only, if you have a different version of the system, please use the official documentation.
Adding keys:
Copy sudo apt-get install -y gnupg
Copy curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
--dearmor
Copy echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] http://repo.mongodb.org/apt/debian buster/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
Installation:
Copy sudo apt-get install -y mongodb-org
Starting and adding to autorun:
Copy sudo systemctl start mongod
Copy sudo systemctl daemon-reload
Copy sudo systemctl enable mongod
Creating a database and password:
continue with the instructions below...
Attention! In the code below there are variables you need to make up your own (ADMIN_NAME, ADMIN_PASSWORD, DB_NAME, USER_NAME, YOUR_PASSWORD, DB_NAME
) these data should not be disclosed to anyone, they are accesses to your databases, if you disclose them or use the command without changes, you risk being hacked!
Copy use admin;
db.createUser({
user: "ADMIN_NAME",
pwd: "ADMIN_PASSWORD",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
});
use DB_NAME;
db.createUser({
user: "USER_NAME",
pwd: "YOUR_PASSWORD",
roles: [ { role: "readWrite", db: "DB_NAME" } ]
});
exit
Copy security:
authorization: "enabled"