MongoDB MCQs – Security

MongoDB security is a critical aspect of database administration, ensuring that data is protected from unauthorized access, breaches, and other vulnerabilities. MongoDB provides several built-in security features, including authentication, authorization, encryption, and auditing.

These MCQs cover fundamental and advanced concepts of MongoDB security, which are frequently tested in technical interviews.

1.) Which of the following is a MongoDB security feature?

A) Sharding
B) Replication
C) Authentication
D) Indexing

Answer: Option C

Explanation: Authentication is a MongoDB security feature that ensures only authorized users can access the database.

2.) What is the default authentication mechanism in MongoDB?

A) LDAP
B) SCRAM-SHA-1
C) Kerberos
D) X.509

Answer: Option B

Explanation: SCRAM-SHA-1 is the default authentication mechanism in MongoDB.

3.) Which command is used to create a user in MongoDB?

A) db.createUser()
B) db.addUser()
C) db.newUser()
D) db.insertUser()

Answer: Option A

Explanation: The command used to create a user in MongoDB is db.createUser(). This command is run on the database where you want to create the user and requires specifying the user’s username, password, and roles.

4.) What is the purpose of roles in MongoDB?

A) To define user permissions
B) To encrypt data
C) To compress data
D) To back up data

Answer: Option A

Explanation: Roles in MongoDB are used to define user permissions. They specify the actions that a user is allowed to perform on the database, such as read, write, or administrative tasks.

5.) Which role provides full administrative access to a MongoDB database?

A) read
B) readWrite
C) dbAdmin
D) root

Answer: Option D

Explanation: The root role provides full administrative access across the entire MongoDB deployment, including all databases. This role has the highest level of privileges and can perform any administrative or operational task within the MongoDB environment.

6.) What is the purpose of the db.grantRolesToUser() command?

A) To create a new user
B) To assign roles to an existing user
C) To encrypt data
D) To back up data

Answer: Option B

Explanation: The db.grantRolesToUser() command assigns roles to an existing user.

7.) Which of the following is true about MongoDB encryption?

A) It encrypts data at rest and in transit
B) It only encrypts data at rest
C) It only encrypts data in transit
D) It does not support encryption

Answer: Option A

Explanation: MongoDB supports encryption for data at rest and in transit.

8.) Which command is used to enable SSL/TLS in MongoDB?

A) mongod –secure
B) mongod –enableSSL
C) mongod –encrypt
D) mongod –sslMode requireSSL

Answer: Option D

Explanation: The mongod –sslMode requireSSL command enables SSL/TLS in MongoDB.

9.) What is the purpose of the auditLog in MongoDB?

A) To log all queries
B) To log all authentication attempts
C) To log all administrative actions
D) To log all read operations

Answer: Option C

Explanation: The auditLog logs all administrative actions for auditing purposes.

10.) Which command is used to enable auditing in MongoDB?

A) mongod –auditDestination file
B) mongod –enableAudit
C) mongod –logAudit
D) mongod –audit

Answer: Option A

Explanation: The mongod –auditDestination file command enables auditing in MongoDB.

Leave a Reply

Your email address will not be published. Required fields are marked *