Now, you’ve successfully covered install mongodb on Ubuntu.
Now let’s create the administrator username and set a password for the username: > db.createUser() Inside the mongo shell type this command to switch to the admin database: > use admin Next, Set up MongoDB administrator username and password first we need to open the MongoDB shell, type in: $ mongo Configuring MongoDB administrator username Reload the system daemon to apply changes $ sudo systemctl daemon-reload 3. # network interfacesīindIp: 0.0.0.0 # to bind to all interfaces Open MongoDB configuration file /etc/nf and change bindIp by adding required $ sudo nano /etc/nfīy default MongoDB accepts connection from localhost only for security reason.Ĭhange the bindIp from 127.0.0.1 to 0.0.0.0 OR you can add any IP those you want to give access. Allow Remote Accessīy default, MongoDB is listening on 127.0.0.1:27017 only: Output: Created symlink from /etc/systemd/system//rvice to /lib/systemd/system/rvice. └─28327 /usr/bin/mongod -quiet -auth -config /etc/nfĮnable MongoDB at System startup $ sudo systemctl enable mongod Loaded: loaded (/lib/systemd/system/rvice enabled vendor preset: enabled)Īctive: active (running) since Sat 16:55:07 UTC 1 weeks 2 days ago Now check to see if the service is running: Start the MongoDB service $ sudo systemctl start mongod Using above commands we have added apt repository for MongoDB 4.0 community Edition, below is command to install MongoDB, $ sudo apt-get install -y mongodb-org
Update the system package using below command, $ sudo apt-get update 3. $ echo "deb xenial/mongodb-org/4.2 multiverse" | sudo tee /etc/apt//mongodb-org-4.2.list $ echo "deb bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt//mongodb-org-4.2.list Ubuntu 16.04 Xenial Once GPG key imported, Add the MongoDB official APT repository in /etc/apt//mongodb-org-4.2.list using below command as per version of Ubuntu Ubuntu 18.04 Bionic $ sudo wget -qO - | sudo apt-key add - 2. Import MongoDB Public GPG Keyįirst download and import MongoDB public GPG key in your system. etc.Here, we are installing MongoDB 4.0 Community Edition on Ubuntu 18.04 and 16.04.
MongoDB is a high-performance database program, used by one of the biggest companies in the world like Facebook,Google, Adobe,SAP, TrendMicro, Verizon, BarClays. MongoDB is a free and open source document-oriented NoSQL and cross-platform database server used for high volume data storage.It uses JSON like documents which makes the database very flexible and scalable.