Get the App
SLTechnology News&Howtos  ›  Servers  › 

Ubuntu 18.04 configure MongoDB password login

Shulou Source: shulou.com Published: 2022-06-03 06:39:31 09月21日 Update

System:

Ubuntu 18.04

MongoDB: 4.2,3

Install MongoDB server and client (for testing) # add MongoDB GPG key apt-key adv-- keyserver hkp://keyserver.ubuntu.com:80-- recv 4B7C549A058F8B6B# create MongoDB repository echo "deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee / etc/apt/sources.list.d/mongodb.listapt-get updateapt-get install mongodb-orgapt-get install mongodb-clients launch MongoDB

Systemctl start mongod.service

Log in to MongoDB and set password # Log in to mongo# and switch to admin database use admin# to create admin account. Password: admin111 permission: root permission, authorized database name: admindb.createUser ({user: "admin", pwd: "admin111", roles: [{role: "root", db: "admin"}]})

Edit MongoDB profile

Vim / etc/mongod.confnet: port: 27017 # Port bindIp: 0.0.0.0 # allowed access address, 0.0.0.0 indicates all security: authorization: enabled

Restart the MongoDB service

Systemctl restart mongod.service

Test login

Mongo-u admin-p admin111-- authenticationDatabase admin

Tags: Login password data database permissions test configuration address key file port system account switch storage service Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB MySQL Redmi Docker Shulou Tech Info