Last active
April 19, 2022 12:42
-
-
Save gigabyteservice/3ed2e0b46face796c1ff109d3ce7965d to your computer and use it in GitHub Desktop.
How to Install MongoDB on Ubuntu 20.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt update | |
sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common | |
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - | |
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list | |
sudo apt update | |
sudo apt install mongodb-org | |
sudo systemctl stop mongod | |
sudo systemctl start mongod | |
sudo systemctl enable mongod | |
sudo systemctl status mongod | |
mongo --host 127.0.0.1:27017 | |
sudo nano /etc/mongod.conf | |
security: | |
authorization: enabled | |
mongo | |
> use admin | |
db.createUser( | |
{ | |
user: "admin", | |
pwd: "strong_password_here", | |
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] | |
} | |
) | |
db.grantRolesToUser('admin', [{ role: 'root', db: 'admin' }]) | |
exit | |
mongo --port 27017 -u "admin" -p "xxxxx" --authenticationDatabase "admin" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment