Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # To see all avaible os an versions, go to https://www.mongodb.com/try/download/community
- did=ubuntu2204
- version=8.0.3
- wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-$did-$version.tgz
- gunzip mongodb-linux-x86_64-$did-$version.tgz
- tar xvf mongodb-linux-x86_64-$did-$version.tar
- mv mongodb-linux-x86_64-$did-$version /usr/local/mongodb
- rm -r /usr/local/mongodb/LICENSE-Community.txt /usr/local/mongodb/MPL-2 /usr/local/mongodb/THIRD-PARTY-NOTICES /usr/local/mongodb/README
- rm -r mongodb-linux-x86_64-$did-$version.tar
- mkdir /usr/local/mongodb/db
- chmod -R 755 /usr/local/mongodb
- /usr/local/mongodb/bin/mongod --dbpath /usr/local/mongodb/db --bind_ip_all &
- echo $! > /usr/local/mongodb/pid
- ln -fs /usr/local/mongodb/bin/* /usr/bin
- # Connect
- mongosh --port 27017 -u USER_NAME -p 'PASSWORD' --authenticationDatabase 'admin'
- # Create user
- ## Global perms
- db.createUser(
- {
- user: "USER_NAME",
- pwd: "PASS",
- roles: [ { role: "root", db: "admin" } ]
- }
- )
- ## Local on a database
- db.createUser(
- {
- user: "USERNAME",
- pwd: "PASS",
- roles: [ { role: "dbOwner", db: "DB_NAME" } ]
- }
- )
- # Delete user
- db.dropUser("USER_NAME")
- # To shutdown
- kill $(cat /usr/local/mongodb/db/mongod.lock)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement