September 5, 2020

Create a Read Only MongoDB User

Activities, Android Developer, Ansible, Apache2, Atlassian, Ayo Belajar Linux, Bestpath Network, BLC Telkom Klaten, BSD, Caddy Server, Case Study, Cisco, Cisco Indonesia, Cloud Computing, Cockpit, Custom Weapons, Docker, E-Learning, Engenius, Error, FreeBSD, FreeBSD Indonesia, Komunitas Pengguna Linux Indonesia, KPLI Bulukumba, KPLI Klaten, Let's Encrypt, Linux, MacOS, Microsoft Azure, Microsoft SQL Server, MikroTik, MikroTik Indonesia, MySQL, Nginx, Open edX, OpenSID, Others, PHP, phpMyAdmin, PostgreSQL, Proxmox, Python, Redash, Sendy, SSH, Stories, Subnetting, TP-Link, Ubiquiti, Unix, Virtualization, Windows, X-Mosque, Faizar Septiawan, Icar, siBunglonGanteng, Orang Ganteng, siBunglonLabs

There are times when you need account read only access to a database.

To create a read only database user MongoDB, do the following steps:

  1. Login as a MongoDB administrator.
$ mongo -u admin -p --authenticationDatabase admin
  1. Show list of database on MongoDB.
>>> show dbs
  1. Select database.
>>> use edxapp
  1. Create a new user with permission read only on the database.
>>> db.createUser({user: "edxapp_read", pwd: "password", roles: [{role: "read", db: "edxapp"}]})
  1. Done.