
MongoDB is a NoSQL database application used to store data as JSON-like documents on servers. MongoDB has modern infrastructure with various services while being malleable and friendly to use, providing freedom to developers and their code.
This guide will explain how to install and configure MongoDB fundamentals on your Debian 11 Instance.
Install the additional packages used to install MongoDB.
Add the MongoDB public GPG key.
Add MongoDB's repository to your instance.
Update your instance.
Install MongoDB.
Verify MongoDB was successfully installed.
Start the MongoDB service.
Enable MongoDB to start when the instance boots.
Creating users in MongoDB's environment is simple and useful to authorize yourself in specific databases and access features within MongoDB.
Enter MongoDB's shell, Mongosh. You can connect to a MongoDB Deployment. However, in this guide, we are connecting to a MongoDB instance running on our localhost.
By default, you will be using the test database. You can display what database you are using by entering db in Mongosh. Let's switch the database to the admin database.
To create a new user, enter this code block within Mongosh. You can add your own unique User and Password.
Successfully creating a new user, Mongosh prompts the following output.
Show the available users on the database.
You can exit Mongosh by pressing Ctrl+C twice, Ctrl+D, or by entering .exit in Mongosh.
MongoDB's standard is to disable authentication when using databases. To secure your database, it's fundamental to have user authentication enabled within MongoDB.
Enter the MongoDB configuration file using your desired text editor.
Paste this code block into the MongoDB configuration file to enable authentication.
Save and exit the configuration file, then restart MongoDB.
Enter Mongosh with your username and password.
Successfully authenticating, Mongosh prompts the following output.
In this guide, you have learned how to install, add users, authenticate, and use databases within MongoDB.
0 Comments
Be the first to comment and share your perspective with the community.