Setting Up an Online MongoDB Database
1. Create a MongoDB Atlas Account
- Open a new tab in your web browser and go to account.mongodb.com/account/register.
- Fill out the required information and create your account.
2. Create a New Project
- After setting up your account, click on the “New Project” button and give it a name (e.g., “LibreChat”).
3. Build a Database
- Click on the “Build a Database” button.
4. Choose the Free Tier
- Select the “Shared Clusters” option, which is the free tier.
5. Name Your Cluster
- Give your cluster a name (e.g., “LibreChat-Cluster”) and click “Create Cluster”.
6. Set Up Database Credentials
- Click on the “Database Access” option in the sidebar.
- Click on the “Add New Database User” button.
- Enter a username and a secure password, then click “Add User”.
7. Configure Network Access
- Click on the “Network Access” option in the sidebar.
- Click on the “Add IP Address” button.
- Select “Allow Access from Anywhere” and click “Confirm”.
8. Get Your Connection String
- Click on the “Databases” option in the sidebar.
- Click on the “Connect” button.
- Select “Connect Your Application”.
- Copy the connection string provided.
- Replace
<password>
in the connection string with the password you set in Step 6. Remove the<>
characters around the password. - Remove
&w=majority
from the end of the connection string. - Add your desired database name (e.g., “LibreChat”) after the host name in the connection string.
Your final connection string should look something like this:
Connection String
mongodb+srv://username:[email protected]/LibreChat?retryWrites=true
9. Update the .env File
- In your LibreChat project, open the
.env
file. - Find the
MONGO_URI
variable and paste your connection string:
.env
MONGO_URI=mongodb+srv://username:[email protected]/LibreChat?retryWrites=true
That’s it! You’ve now set up an online MongoDB database for LibreChat using MongoDB Atlas, and you’ve updated your LibreChat application to use this database connection. Your application should now be able to connect to the online MongoDB database.
Note about Docker
✏️
Docker