const { MongoClient, ServerApiVersion } = require('mongodb');
const uri="mongodb+srv://nunsence1:test1234@cluster0.mbj4n.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0";
// Create a MongoClient with a MongoClientOptions object to set the Stable API version
const client = new MongoClient(uri, {
serverApi: {
version: ServerApiVersion.v1,
strict: true,
deprecatis: true,
}
});
async function run() {
try {
// Connect the client to the server (optional starting in v4.7)
await client.connect();
// Send a ping to confirm a successful connection
await client.db("admin").command({ ping: 1 });
console.log("Pinged your deployment. You successfully connected to MongoDB!");
} finally {
// Ensures that the client will close when you finish/error
await client.close();
}
}
run().catch(console.dir);
아이디랑 비번 맞는데 왜 자꾸 인증실패라 뜨는지 이해가 안가요 ㅠ
appName지정 제대로 안된거 아님? 컴파스 접속할때 ?뒤에 다 빼봐
https://www.mongodb.com/docs/atlas/compass-connection/
TLS
필요하다는거 같은데, 이미 있음?
여기 코드로는 알 수 없네.