Last active
July 16, 2021 09:47
-
-
Save ayrilmaz/9a041cb55a652735d3661683a070e0e9 to your computer and use it in GitHub Desktop.
Ubuntu Mongodb
This file contains 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-4.4.asc | sudo apt-key add - | |
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list | |
sudo apt-get update | |
sudo apt-get install -y mongodb-org | |
sudo systemctl start mongod.service | |
sudo systemctl enable mongod | |
#config | |
sudo nano /etc/mongod.conf | |
# network interfaces | |
net: | |
port: 27017 | |
bindIp: 0.0.0.0 | |
#create user | |
Show dbs | |
use newDb | |
db.createUser({user: "new-user",pwd: "Dc#pass",roles: [ { role: 'dbOwner', db: 'newDb'} ]}) | |
#uninstall | |
$ sudo service mongod stop | |
$ sudo apt-get purge mongodb-org* | |
$ sudo rm -r /var/log/mongodb | |
$ sudo rm -r /var/lib/mongodb | |
#servise error | |
#ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14) | |
sudo rm -rf /tmp/mongodb-27017.sock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment