11/30/2024
You can choose between the two, you don't have to install or use both of them. I recommend using MongoDB Atlas if you can because you don't need to install anything and the database is already on the cloud and you can find free hosting services to deploy your website.
winget install MongoDB.Shell
mongosh
use yourdatabase
db.createCollection("yourcollectionname")
Now you can just leave it like that
Create your MongoDB Atlas account https://www.mongodb.com/cloud/atlas/register
After selecting your project, cluster, and server location, you can add your IP address in the Network Access tab under SECURITY. If you want, you can check for Allow access from anywhere so that you don't have to do this again.
Make sure you are on the right project, you can click on Clusters tab under DATABASE.
Here you can see your cluster's name. Then, you can click on connect.
Click on Drivers. Select your driver's version and copy your connection string
Replace <db_password> with your password that you've created earlier.
Try this step :
- Click on Database Access under SECURITY
- Click EDIT
- Click Edit Password
- Click Auto Regenerate Secure Password
- Click Copy
Error: queryTxt ETIMEOUT cluster0-ghis2.mongodb.net at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19) { errno: 'ETIMEOUT', code: 'ETIMEOUT', syscall: 'queryTxt', hostname: 'cluster0-ghis2.mongodb.net' }I was having an issue connecting to MongoDB Atlas because of a DNS record problem. Maybe you can try this steps :
- Change your DNS to using google dns
8.8.8.8or8.8.4.4- Or you can try changing the driver's version (Step 5) to
2.2.12 or later
# For Windows Only
winget install OpenJS.NodeJS.LTS
More about NodeJS : https://nodejs.org/
# For windows only
winget install Microsoft.VisualStudioCode
More about Visual Studio Code : https://code.visualstudio.com/
git clone https://github.com/get543/Markdown-Blog.git
npm install
.env file and add thisThis is just an example
SESSION_STATS=dev
MONGO_DEV_URI=mongodb://localhost:27017/yourdatabase
MONGO_PROD_URI=mongodb+srv://username:password@youcluster.z2g8s.mongodb.net/yourdatabase?retryWrites=true&w=majority&appName=Yourcluster
MONGO_DEV_URI : URI for connecting to local/remote server (in this case local server)
MONGO_PROD_URI : URI for cloud database (in this case MongoDB Atlas)
SESSION_STATS :
prod to use MONGO_PROD_URIdev to use MONGO_DEV_URInpm start