MCQs Of Day 2 - Installing MongoDB
1. What is the first step to install MongoDB on Windows?
- A) Download the MongoDB installer
- B) Install the MongoDB service
- C) Start the MongoDB shell
- D) Add MongoDB to the system path
Answer: A) Download the MongoDB installer
Explanation: The first step is to download the .msi installer for MongoDB from the official website before proceeding with the installation.
2. Which command is used to start MongoDB on macOS after installation?
- A) mongo start
- B) mongod --start
- C) brew services start mongodb
- D) mongod --run
Answer: C) brew services start mongodb
Explanation: Homebrew is used for managing services on macOS, and brew services start mongodb starts MongoDB as a background service.
3. What command is used to install MongoDB on Ubuntu Linux?
- A) sudo apt install mongodb
- B) sudo apt install mongodb-org
- C) sudo brew install mongodb
- D) sudo apt install mongo
Answer: B) sudo apt install mongodb-org
Explanation: mongodb-org is the MongoDB package used in Ubuntu to install MongoDB on a system.
4. Which platform does MongoDB support for installation?
- A) Windows only
- B) Linux only
- C) macOS only
- D) Windows, Linux, and macOS
Answer: D) Windows, Linux, and macOS
Explanation: MongoDB supports installation on all three major platforms: Windows, Linux, and macOS.
5. After installing MongoDB on Windows, which command starts the MongoDB server?
- A) mongo start
- B) mongod
- C) start mongod
- D) run mongod
Answer: B) mongod
Explanation: The mongod command is used to start the MongoDB server process, which must be running before any MongoDB clients can connect to it.
6. What command is used to check the status of the MongoDB service on Linux?
- A) systemctl status mongo
- B) mongo status
- C) systemctl status mongod
- D) mongod status
Answer: C) systemctl status mongod
Explanation: The systemctl status mongod command is used to check the status of the MongoDB service on Linux systems.
7. How do you connect to MongoDB from the shell after installation on macOS?
- A) mongo connect
- B) mongo
- C) start mongo
- D) connect mongo
Answer: B) mongo
Explanation: After installation, running the mongo command in the terminal connects you to the MongoDB shell.
8. What is the default port for MongoDB?
- A) 27017
- B) 3000
- C) 8080
- D) 5432
Answer: A) 27017
Explanation: The default port for MongoDB is 27017. It can be changed by modifying the configuration file.
9. What is MongoDB's default database called?
- A) system
- B) admin
- C) test
- D) defaultDB
Answer: C) test
Explanation: After installation, MongoDB connects to a default database called test unless specified otherwise.
10. In which configuration file do you configure MongoDB to run as a service?
- A) mongo.conf
- B) mongod.conf
- C) config.mongo
- D) service.mongo
Answer: B) mongod.conf
Explanation: The mongod.conf file is used to configure MongoDB, including setting it to run as a service on system startup.
11. What is the role of the mongod command in MongoDB?
- A) It connects to MongoDB
- B) It runs the MongoDB shell
- C) It starts the MongoDB server process
- D) It installs MongoDB
Answer: C) It starts the MongoDB server process
Explanation: mongod is the process that runs the MongoDB server. It must be running to handle requests from clients.
12. What command is used to stop MongoDB on Linux?
- A) sudo systemctl stop mongo
- B) sudo systemctl stop mongod
- C) mongo stop
- D) sudo mongod stop
Answer: B) sudo systemctl stop mongod
Explanation: To stop the MongoDB service on Linux, you use sudo systemctl stop mongod.
13. How do you verify MongoDB is running after installation on Windows?
- A) Check Task Manager for mongod.exe
- B) Run mongo command
- C) Check the Event Viewer
- D) All of the above
Answer: D) All of the above
Explanation: You can check if MongoDB is running through Task Manager, Event Viewer, or by connecting to MongoDB using the mongo shell.
14. What does the --bind_ip option in the mongod command do?
- A) Defines the IP address MongoDB listens on
- B) Specifies the port for MongoDB
- C) Defines the database to use
- D) Configures the logging level
Answer: A) Defines the IP address MongoDB listens on
Explanation: The --bind_ip option specifies which IP addresses MongoDB should bind to and listen for connections.
15. How do you configure MongoDB to start automatically on startup in Ubuntu?
- A) sudo systemctl enable mongod
- B) sudo enable mongod
- C) sudo systemctl start mongod
- D) sudo start mongod
Answer: A) sudo systemctl enable mongod
Explanation: The sudo systemctl enable mongod command configures MongoDB to start automatically at system boot.
16. What is the MongoDB shell used for?
- A) Managing the MongoDB server
- B) Interacting with the MongoDB database
- C) Configuring MongoDB settings
- D) Installing MongoDB
Answer: B) Interacting with the MongoDB database
Explanation: The MongoDB shell (mongo) is used to interact with MongoDB, run queries, and perform database operations.
17. Which command is used to exit the MongoDB shell?
- A) exit
- B) quit
- C) logout
- D) stop
Answer: A) exit
Explanation: To exit the MongoDB shell, you can simply type exit.
18. What command checks if MongoDB is running on Linux?
- A) mongod status
- B) ps aux | grep mongod
- C) mongo status
- D) systemctl check mongod
Answer: B) ps aux | grep mongod
Explanation: This command checks if the mongod process is running by searching for it in the system's process list.
19. Which package is installed on Linux to install MongoDB?
- A) mongodb
- B) mongodb-org
- C) mongo
- D) mongodb-client
Answer: B) mongodb-org
Explanation: The mongodb-org package includes all necessary MongoDB components for installation on Linux.
20. Where are MongoDB logs typically located on Linux?
- A) /var/log/mongo.log
- B) /usr/local/mongodb/mongo.log
- C) /var/log/mongodb/mongod.log
- D) /etc/mongodb/mongod.log
Answer: C) /var/log/mongodb/mongod.log
Explanation: The default MongoDB log file on Linux is located at /var/log/mongodb/mongod.log.
21. How can you modify the MongoDB configuration file on macOS?
- A) Edit /etc/mongod.conf
- B) Edit /usr/local/etc/mongod.conf
- C) Edit /usr/local/bin/mongod.conf
- D) Edit /var/log/mongod.conf
Answer: B) Edit /usr/local/etc/mongod.conf
Explanation: On macOS, MongoDB's configuration file is typically located at /usr/local/etc/mongod.conf.
22. Which file is used to configure MongoDB on Windows?
- A) mongodb.cfg
- B) mongod.conf
- C) mongod.cfg
- D) mongo.cfg
Answer: C) mongod.cfg
Explanation: The mongod.cfg file is used to configure MongoDB on Windows, including network and storage settings.
23. Which MongoDB command helps to verify the version of MongoDB installed?
- A) mongo version
- B) mongod --version
- C) mongo --version
- D) version
Answer: C) mongo --version
Explanation: The mongo --version command displays the version of the MongoDB shell.
24. How do you stop MongoDB service on macOS?
- A) sudo service stop mongod
- B) sudo brew services stop mongodb
- C) sudo systemctl stop mongod
- D) brew stop mongodb
Answer: B) sudo brew services stop mongodb
Explanation: On macOS, MongoDB can be stopped using sudo brew services stop mongodb.
25. Which port should MongoDB be configured to run on?
- A) 3306
- B) 8080
- C) 27017
- D) 443
Answer: C) 27017
Explanation: The default port for MongoDB is 27017.
26. What is the correct command to check MongoDB status on Windows?
- A) net start mongodb
- B) ps aux | grep mongod
- C) mongod status
- D) services.msc
Answer: D) services.msc
Explanation: On Windows, you can check MongoDB’s status by opening the Services window (services.msc) and looking for the MongoDB service.
27. Which is the correct URL for downloading MongoDB?
- A) https://mongodb.org/download
- B) https://www.mongodb.com/download
- C) https://www.mongodb.org/download
- D) https://mongodb.com/download
Answer: C) https://www.mongodb.org/download
Explanation: The official MongoDB download link is https://www.mongodb.org/download.
28. How do you enable authentication in MongoDB?
- A) Modify the mongod.conf file to set security: {authorization: "enabled"}
- B) Use the --auth flag when running mongod
- C) Both A and B
- D) Modify the mongo.conf file
Answer: C) Both A and B
Explanation: Authentication in MongoDB can be enabled by either modifying the mongod.conf file or using the --auth flag when starting mongod.
29. What does the --fork option do when starting MongoDB?
- A) Forks the MongoDB process to the background
- B) Starts MongoDB in safe mode
- C) Enables authentication
- D) Creates a new database
Answer: A) Forks the MongoDB process to the background
Explanation: The --fork option runs the MongoDB process in the background as a daemon.
30. What is the default location for MongoDB data files on Windows?
- A) C:\MongoDB\data
- B) C:\data\mongo
- C) C:\Program Files\MongoDB\data
- D) C:\MongoDB\server\data
Answer: A) C:\MongoDB\data
Explanation: By default, MongoDB stores its data in C:\MongoDB\data unless configured otherwise in the mongod.conf file.
This is a sample set of MCQs for installing MongoDB. Would you like to continue with more questions, or do you need another type of assistance?
4o mini
You said:
yes
ChatGPT said:
ChatGPT
Here are additional multiple-choice questions (MCQs) related to MongoDB installation and configuration:
31. Which file is used to configure MongoDB settings on Linux?
- A) mongod.conf
- B) mongodb.config
- C) config.mongodb
- D) mongo.conf
Answer: A) mongod.conf
Explanation: MongoDB uses the mongod.conf file to configure settings such as network and storage options.
32. How can you start MongoDB on Linux using systemd?
- A) sudo service mongod start
- B) sudo systemctl start mongod
- C) sudo start mongodb
- D) sudo mongod start
Answer: B) sudo systemctl start mongod
Explanation: On systems that use systemd, MongoDB can be started with sudo systemctl start mongod.
33. Which of the following is the default data directory for MongoDB on Linux?
- A) /data/db
- B) /usr/local/mongo
- C) /var/lib/mongo
- D) /mongodb/data
Answer: A) /data/db
Explanation: The default data directory for MongoDB is /data/db unless otherwise configured in mongod.conf.
34. What is the purpose of the --bind_ip option when starting MongoDB?
- A) Sets the IP address MongoDB binds to for accepting connections
- B) Configures the IP address MongoDB uses to connect to the network
- C) Enables MongoDB authentication
- D) Specifies the IP address for data replication
Answer: A) Sets the IP address MongoDB binds to for accepting connections
Explanation: The --bind_ip option specifies the IP address on which MongoDB listens for incoming connections.
35. What is the command to connect to a running MongoDB instance?
- A) mongo connect
- B) mongod --connect
- C) mongo
- D) mongo connect --host
Answer: C) mongo
Explanation: The mongo command is used to connect to a running MongoDB instance from the shell.
36. Which of the following is the correct command to stop MongoDB service on Linux?
- A) sudo systemctl stop mongodb
- B) sudo service mongod stop
- C) sudo systemctl stop mongod
- D) sudo service mongodb stop
Answer: C) sudo systemctl stop mongod
Explanation: The correct command to stop MongoDB on Linux is sudo systemctl stop mongod.
37. Which MongoDB version supports the WiredTiger storage engine by default?
- A) 2.6
- B) 3.0
- C) 4.0
- D) 5.0
Answer: B) 3.0
Explanation: MongoDB 3.0 introduced the WiredTiger storage engine as the default storage engine.
38. How can you view the logs of MongoDB while it is running?
- A) Check the logfile in the mongod.conf configuration file
- B) Use the mongod --log command
- C) tail -f /var/log/mongodb/mongod.log
- D) Open the MongoDB console logs directly
Answer: C) tail -f /var/log/mongodb/mongod.log
Explanation: The command tail -f /var/log/mongodb/mongod.log is used to continuously view MongoDB logs on Linux.
39. What is the default authentication method for MongoDB when running with authentication enabled?
- A) SCRAM-SHA-256
- B) SCRAM-SHA-1
- C) MONGODB-CR
- D) LDAP
Answer: B) SCRAM-SHA-1
Explanation: MongoDB uses SCRAM-SHA-1 as the default authentication mechanism when authentication is enabled.
40. How do you uninstall MongoDB on Windows?
- A) Uninstall from the Control Panel
- B) Run mongo --uninstall
- C) Delete the MongoDB files manually
- D) Use sudo apt-get purge mongodb (for Linux)
Answer: A) Uninstall from the Control Panel
Explanation: MongoDB can be uninstalled on Windows from the Control Panel under Programs and Features.
41. What is the default port MongoDB uses for client connections?
- A) 8080
- B) 3306
- C) 27017
- D) 1433
Answer: C) 27017
Explanation: MongoDB uses port 27017 by default for client connections.
42. What command is used to enable MongoDB as a service on Windows?
- A) mongod --install
- B) net start mongod
- C) mongod --service
- D) sc create MongoDB binPath= "C:\Program Files\MongoDB\bin\mongod.exe"
Answer: D) sc create MongoDB binPath= "C:\Program Files\MongoDB\bin\mongod.exe"
Explanation: This command sets up MongoDB as a service on Windows.
43. Which of the following is NOT a valid MongoDB storage engine?
- A) WiredTiger
- B) MMAPv1
- C) InnoDB
- D) RocksDB
Answer: C) InnoDB
Explanation: InnoDB is a storage engine for MySQL, not MongoDB. MongoDB uses WiredTiger, MMAPv1, and RocksDB as storage engines.
44. How do you back up a MongoDB database?
- A) mongodump
- B) mongoexport
- C) backup_mongo
- D) mongobackup
Answer: A) mongodump
Explanation: The mongodump command is used to create backups of a MongoDB database.
45. Which command is used to restore a MongoDB backup?
- A) mongorestore
- B) mongoimport
- C) restore_mongo
- D) restore --mongo
Answer: A) mongorestore
Explanation: The mongorestore command is used to restore a backup created with mongodump.
Would you like to continue with more questions, or is there another specific area you want to focus on?
4o mini
You said:
yes
ChatGPT said:
ChatGPT
Here are additional MongoDB installation and configuration related multiple-choice questions (MCQs):
46. Which command is used to start the MongoDB server in the background on Linux?
- A) sudo systemctl start mongod --fork
- B) mongod --fork
- C) mongod --daemon
- D) systemctl start mongod
Answer: B) mongod --fork
Explanation: The --fork option runs the mongod process in the background, allowing the MongoDB server to run as a daemon.
47. Which MongoDB tool is used to migrate MongoDB data to another MongoDB instance?
- A) mongodump
- B) mongoexport
- C) mongorestore
- D) mongoreplicate
Answer: A) mongodump
Explanation: mongodump is used to create backups, which can later be restored using mongorestore, effectively migrating MongoDB data between instances.
48. Which of the following platforms does MongoDB officially support for installation?
- A) Windows only
- B) macOS only
- C) Linux only
- D) Windows, macOS, and Linux
Answer: D) Windows, macOS, and Linux
Explanation: MongoDB officially supports installation on Windows, macOS, and Linux platforms.
49. What is the default database storage location for MongoDB on Windows?
- A) C:\mongodb\data
- B) C:\MongoDB\data
- C) C:\Program Files\MongoDB\data
- D) C:\data\mongo
Answer: B) C:\MongoDB\data
Explanation: The default data storage location for MongoDB on Windows is C:\MongoDB\data.
50. How can you verify if MongoDB is running on your system?
- A) By running the ps -aux | grep mongod command
- B) By running mongo --status
- C) By checking the MongoDB service in the Control Panel
- D) By opening MongoDB logs directly
Answer: A) By running the ps -aux | grep mongod command
Explanation: Running ps -aux | grep mongod on Linux shows whether the mongod process is running.
51. What does the --logpath option do in MongoDB?
- A) Specifies the log file where MongoDB writes logs
- B) Configures the storage engine path
- C) Defines the path for MongoDB backups
- D) Enables MongoDB logging in a specific location
Answer: A) Specifies the log file where MongoDB writes logs
Explanation: The --logpath option specifies where MongoDB writes its log files.
52. Which of the following tools helps to import data into MongoDB from CSV or JSON files?
- A) mongoimport
- B) mongodump
- C) mongorestore
- D) mongoexport
Answer: A) mongoimport
Explanation: The mongoimport tool helps import data into MongoDB from CSV or JSON files.
53. Which configuration file is used to configure MongoDB’s behavior on Linux?
- A) mongodb.conf
- B) mongod.conf
- C) config.mongodb
- D) mongo.conf
Answer: B) mongod.conf
Explanation: The mongod.conf file is used to configure MongoDB's behavior, including settings like network interfaces and storage options.
54. What command is used to check the version of MongoDB?
- A) mongod --version
- B) mongo --version
- C) mongod -v
- D) mongo -v
Answer: B) mongo --version
Explanation: The mongo --version command shows the version of the MongoDB shell.
55. Which directory should MongoDB be installed in on Windows?
- A) C:\Program Files\MongoDB
- B) C:\MongoDB
- C) C:\Mongo
- D) C:\data\mongo
Answer: A) C:\Program Files\MongoDB
Explanation: The default installation directory for MongoDB on Windows is C:\Program Files\MongoDB.
56. Which command is used to check MongoDB service status on macOS?
- A) brew services status mongodb
- B) systemctl status mongod
- C) mongod status
- D) service mongod status
Answer: A) brew services status mongodb
Explanation: On macOS, brew services status mongodb is used to check the status of MongoDB if installed via Homebrew.
57. What is the command to enable MongoDB as a service on Linux using systemd?
- A) sudo systemctl enable mongod
- B) sudo systemctl start mongod
- C) sudo service mongod enable
- D) sudo systemctl mongod start
Answer: A) sudo systemctl enable mongod
Explanation: The command sudo systemctl enable mongod enables MongoDB to start automatically on system boot.
58. Which of the following is the default port MongoDB listens on?
- A) 8080
- B) 3306
- C) 27017
- D) 443
Answer: C) 27017
Explanation: By default, MongoDB listens for client connections on port 27017.
59. How do you disable authentication in MongoDB?
- A) Set security: {authorization: "disabled"} in mongod.conf
- B) Use the --noauth flag when starting mongod
- C) Remove the authentication settings from the mongod.conf file
- D) All of the above
Answer: D) All of the above
Explanation: Authentication can be disabled by either modifying the mongod.conf file or using the --noauth flag.
60. Which of the following is used to set up authentication for MongoDB?
- A) Modify mongod.conf to include security: {authorization: "enabled"}
- B) Use the --auth flag while starting mongod
- C) Both A and B
- D) Modify MongoDB service configuration
Answer: C) Both A and B
Explanation: Authentication can be enabled in MongoDB by either using the --auth flag or modifying the mongod.conf file.
These questions can help strengthen your understanding of MongoDB installation and configuration. Would you like more questions or another topic covered?
4o mini
You said:
yes
ChatGPT said:
ChatGPT
Here are more MongoDB-related multiple-choice questions:
61. What is the purpose of the mongod process in MongoDB?
- A) It is used to monitor the performance of the database.
- B) It is responsible for managing the database's operations and data storage.
- C) It is used to export data from the MongoDB database.
- D) It handles client connections only.
Answer: B) It is responsible for managing the database's operations and data storage.
Explanation: The mongod process is the primary process that runs the MongoDB server and manages data operations, including storage, retrieval, and data management.
62. Which file is used to configure MongoDB when installed using Homebrew on macOS?
- A) mongod.conf
- B) mongodb.conf
- C) brew.conf
- D) mongo.homebrew
Answer: A) mongod.conf
Explanation: The mongod.conf file is the configuration file used to set MongoDB server settings, regardless of the installation method (including using Homebrew on macOS).
63. What is the default directory for MongoDB logs on Linux?
- A) /var/log/mongodb
- B) /home/mongodb/logs
- C) /usr/local/mongodb/logs
- D) /etc/mongodb/logs
Answer: A) /var/log/mongodb
Explanation: The default directory for MongoDB logs on Linux systems is /var/log/mongodb.
64. What is the first step in configuring MongoDB on a Windows machine after installation?
- A) Create a new database
- B) Start the MongoDB service
- C) Create a data directory for storage
- D) Set up a user for authentication
Answer: C) Create a data directory for storage
Explanation: The first step after installing MongoDB on Windows is to create the directory where MongoDB will store its data (C:\MongoDB\data by default).
65. What is the command used to stop the MongoDB server process in Linux?
- A) sudo systemctl stop mongod
- B) sudo mongod stop
- C) sudo service mongod stop
- D) sudo kill -9 <pid>
Answer: A) sudo systemctl stop mongod
Explanation: The command sudo systemctl stop mongod is used to stop the MongoDB service running in Linux.
66. After installing MongoDB on Windows, which command should be used to start the MongoDB shell?
- A) mongod
- B) mongo
- C) mongos
- D) start mongo
Answer: B) mongo
Explanation: The mongo command is used to start the MongoDB shell to interact with the database. The mongod command is used to start the MongoDB server.
67. Which of the following installation methods is recommended for MongoDB on macOS?
- A) Installing MongoDB using the official .dmg file
- B) Installing MongoDB using the Homebrew package manager
- C) Installing MongoDB from the official website as a .tar file
- D) Installing MongoDB using the brew install method only
Answer: B) Installing MongoDB using the Homebrew package manager
Explanation: Homebrew is the recommended package manager for macOS because it simplifies the installation and management of MongoDB and its dependencies.
68. Which command is used to install MongoDB on a Linux system using apt-get package manager?
- A) sudo apt-get install mongodb
- B) sudo apt-get install mongodb-server
- C) sudo apt-get install mongo
- D) sudo apt-get install mongodb-org
Answer: D) sudo apt-get install mongodb-org
Explanation: On Ubuntu or Debian-based Linux distributions, the correct command to install MongoDB is sudo apt-get install mongodb-org.
69. What should be done before using MongoDB for the first time after installation?
- A) Start the mongod process
- B) Create a user for authentication
- C) Start the MongoDB shell
- D) Both A and B
Answer: D) Both A and B
Explanation: After installation, the mongod process must be started, and users may want to configure authentication by creating a user.
70. What is the MongoDB configuration file used for?
- A) It holds user credentials.
- B) It defines the server's runtime parameters such as port, storage location, and authentication.
- C) It stores all database data.
- D) It contains all the queries and commands executed by MongoDB.
Answer: B) It defines the server's runtime parameters such as port, storage location, and authentication.
Explanation: The mongod.conf file defines the configuration settings for MongoDB, including storage paths, networking settings, authentication, and more.
71. How do you ensure that MongoDB starts automatically after a system reboot on Linux using systemd?
- A) Run the command sudo systemctl enable mongod
- B) Modify the mongod.conf file
- C) Use the --reboot flag while starting mongod
- D) Manually start MongoDB after reboot
Answer: A) Run the command sudo systemctl enable mongod
Explanation: The command sudo systemctl enable mongod ensures that MongoDB starts automatically when the system reboots.
72. What type of storage engine is used by MongoDB by default?
- A) In-Memory Storage Engine
- B) WiredTiger
- C) RocksDB
- D) MMAPv1
Answer: B) WiredTiger
Explanation: WiredTiger is the default storage engine used by MongoDB, offering improved performance and compression over older engines like MMAPv1.
73. What is the purpose of the MongoDB data directory?
- A) It stores the database logs.
- B) It stores the database files such as collections and indexes.
- C) It stores configuration settings for MongoDB.
- D) It holds backup data for MongoDB.
Answer: B) It stores the database files such as collections and indexes.
Explanation: The MongoDB data directory holds the files related to collections and indexes. These files represent the actual data stored in the database.
74. What is the command to stop MongoDB when running as a service on Windows?
- A) net stop mongodb
- B) mongod stop
- C) service mongodb stop
- D) systemctl stop mongod
Answer: A) net stop mongodb
Explanation: On Windows, net stop mongodb is used to stop the MongoDB service.
75. What is the default port that MongoDB listens on?
- A) 8080
- B) 27017
- C) 3306
- D) 443
Answer: B) 27017
Explanation: The default port that MongoDB listens to is 27017.
These MCQs help reinforce knowledge about MongoDB's installation, configuration, and basic operations. Would you like to continue with more questions or explore another topic?
4o mini
You said:
yes
ChatGPT said:
ChatGPT
Here are additional multiple-choice questions related to MongoDB installation and configuration:
76. Which of the following is true about MongoDB’s data storage model?
- A) Data is stored in relational tables.
- B) Data is stored in documents within collections.
- C) Data is stored in flat files.
- D) Data is stored in binary blobs.
Answer: B) Data is stored in documents within collections.
Explanation: MongoDB is a NoSQL database, and it stores data in documents (BSON format) within collections, which are analogous to tables in relational databases.
77. When installing MongoDB on Ubuntu, which repository is required to install the MongoDB packages?
- A) MongoDB Official Repository
- B) MySQL Repository
- C) Ubuntu Universal Repository
- D) Ubuntu MongoDB Repository
Answer: A) MongoDB Official Repository
Explanation: The official MongoDB repository provides the latest stable version of MongoDB for Ubuntu, ensuring that you install the most recent updates and patches.
78. After installing MongoDB on Linux, which service is used to start the MongoDB server?
- A) sudo service mongod start
- B) sudo systemctl start mongod
- C) sudo mongod --start
- D) sudo start mongod
Answer: B) sudo systemctl start mongod
Explanation: On Linux, the command sudo systemctl start mongod is used to start the MongoDB server if it is configured as a systemd service.
79. What is the default data directory for MongoDB on Linux systems?
- A) /var/db/mongodb
- B) /data/db
- C) /usr/local/mongodb/data
- D) /etc/mongodb/data
Answer: B) /data/db
Explanation: By default, MongoDB stores its data in the /data/db directory on Linux. If the directory doesn’t exist, it needs to be created manually.
80. How do you run MongoDB on Windows in the background as a service?
- A) mongod --background
- B) mongod --service
- C) net start mongodb
- D) mongod --service-start
Answer: C) net start mongodb
Explanation: To run MongoDB as a service on Windows, you can use the net start mongodb command, which starts MongoDB as a background service.
81. When running MongoDB on Linux, what is the command to enable MongoDB to start automatically after a system reboot?
- A) sudo systemctl enable mongodb
- B) sudo systemctl enable mongod
- C) sudo service mongod enable
- D) sudo enable mongod
Answer: B) sudo systemctl enable mongod
Explanation: On Linux, the command sudo systemctl enable mongod ensures MongoDB starts automatically on reboot as a systemd service.
82. In which format are MongoDB data documents stored?
- A) JSON
- B) BSON
- C) XML
- D) CSV
Answer: B) BSON
Explanation: MongoDB stores data in BSON (Binary JSON) format, which is a binary representation of JSON-like documents.
83. What is the minimum amount of disk space required to install MongoDB on a Linux system?
- A) 50 MB
- B) 100 MB
- C) 1 GB
- D) 2 GB
Answer: B) 100 MB
Explanation: MongoDB typically requires at least 100 MB of disk space for a basic installation, but more space is needed for actual data storage, which grows depending on usage.
84. Which command can be used to check the MongoDB version after installation?
- A) mongo --version
- B) mongod --version
- C) mongo -v
- D) Both A and B
Answer: D) Both A and B
Explanation: You can use either mongo --version or mongod --version to check the version of MongoDB installed.
85. How can you stop the MongoDB server on a Linux system running MongoDB as a service?
- A) sudo systemctl stop mongod
- B) sudo service mongod stop
- C) sudo mongod stop
- D) Both A and B
Answer: D) Both A and B
Explanation: Both sudo systemctl stop mongod and sudo service mongod stop are valid commands to stop the MongoDB service on a Linux system, depending on the system's initialization system.
86. Which command is used to connect to a MongoDB instance after installation?
- A) mongo connect
- B) mongo
- C) mongod
- D) mongos connect
Answer: B) mongo
Explanation: The mongo command is used to start the MongoDB shell, which allows users to interact with the MongoDB database.
87. What is the default configuration file used to set MongoDB options on Linux?
- A) mongodb.conf
- B) mongod.conf
- C) mongo.conf
- D) config.mongo
Answer: B) mongod.conf
Explanation: The mongod.conf file is the default configuration file used to configure settings for the MongoDB server.
88. What is a common reason for MongoDB to fail to start after installation?
- A) The data directory does not exist.
- B) MongoDB is not installed as a service.
- C) The system has insufficient disk space.
- D) All of the above
Answer: D) All of the above
Explanation: MongoDB might fail to start if the data directory is missing, it is not set up as a service, or the system does not have enough disk space for operation.
89. What command is used to verify the status of the MongoDB service on Linux?
- A) sudo systemctl status mongod
- B) sudo service mongod status
- C) mongod status
- D) Both A and B
Answer: D) Both A and B
Explanation: Both sudo systemctl status mongod and sudo service mongod status are used to check the status of the MongoDB service on Linux.
90. What is a common security practice to follow after installing MongoDB?
- A) Disable authentication
- B) Enable authentication and create users
- C) Expose the database to all networks
- D) Install MongoDB without a firewall
Answer: B) Enable authentication and create users
Explanation: After installation, it’s a good practice to enable authentication and create users with specific roles to secure the MongoDB instance.
91. Which of the following commands is used to start MongoDB as a standalone process without the service?
- A) mongod
- B) mongo start
- C) service mongod start
- D) mongod --service
Answer: A) mongod
Explanation: The mongod command is used to start the MongoDB server process manually. It is not a service but a direct execution of the MongoDB server.
92. What is the recommended storage engine for MongoDB 3.2 and later?
- A) WiredTiger
- B) MMAPv1
- C) RocksDB
- D) In-Memory
Answer: A) WiredTiger
Explanation: Starting with MongoDB 3.2, WiredTiger became the default and recommended storage engine, offering better performance and data compression than MMAPv1.
93. How can you configure MongoDB to bind to a specific IP address on Linux?
- A) Modify bind_ip in the mongod.conf file
- B) Use the --bind option when starting mongod
- C) Both A and B
- D) Modify the network.bind setting in the system configuration
Answer: C) Both A and B
Explanation: MongoDB can be configured to bind to a specific IP address by setting the bind_ip option in the mongod.conf file or by using the --bind option when starting the mongod process.
94. What is the purpose of the mongos process in a sharded MongoDB setup?
- A) It manages replica sets.
- B) It is responsible for managing the configuration of MongoDB nodes.
- C) It acts as a routing service to forward client requests to the appropriate shard.
- D) It performs backups of the database.
Answer: C) It acts as a routing service to forward client requests to the appropriate shard.
Explanation: In a sharded MongoDB setup, the mongos process routes client requests to the appropriate shard in the cluster based on the shard key.
95. How do you uninstall MongoDB on a Linux system?
- A) sudo apt-get remove mongodb
- B) sudo apt-get purge mongodb-org
- C) sudo rm -rf /usr/local/mongodb
- D) Both A and B
Answer: D) Both A and B
Explanation: Both commands can be used to remove MongoDB from a Linux system. The second option also removes configuration files related to MongoDB.
Let me know if you need more questions or additional assistance!
4o mini
You said:
rest 5
ChatGPT said:
ChatGPT
Here are the remaining 5 MCQs:
96. What is the default port MongoDB listens on?
- A) 27017
- B) 3306
- C) 5432
- D) 8080
Answer: A) 27017
Explanation: By default, MongoDB listens on port 27017 for incoming connections.
97. Which of the following is a valid method to start MongoDB after installation on macOS?
- A) mongod --start
- B) sudo systemctl start mongod
- C) brew services start mongodb
- D) sudo mongod --start
Answer: C) brew services start mongodb
Explanation: On macOS, if you installed MongoDB using Homebrew, you can start MongoDB using brew services start mongodb.
98. Which configuration file is used to set the log path for MongoDB?
- A) logpath
- B) mongod.conf
- C) log.conf
- D) mongodb.conf
Answer: B) mongod.conf
Explanation: The log path and other configuration options for MongoDB can be set in the mongod.conf file.
99. After installing MongoDB on Windows, what is the default directory for the MongoDB logs?
- A) C:\Program Files\MongoDB\log
- B) C:\data\db
- C) C:\mongodb\logs
- D) C:\mongodb\data
Answer: A) C:\Program Files\MongoDB\log
Explanation: By default, MongoDB logs are stored in the C:\Program Files\MongoDB\log directory on Windows.
100. Which MongoDB shell command is used to display the current version of MongoDB?
- A) db.version()
- B) show version
- C) mongod --version
- D) mongo --version
Answer: D) mongo --version
Explanation: The mongo --version command in the terminal displays the MongoDB shell version installed on the system.
