When I try to run any command from the prisma I get this error message:
$ npx prisma migrate reset
Error: MongoDB error
SCRAM failure: Authentication failed.
0: migration_core::state::Reset
at migration-engine/core/src/state.rs:341
When I run docker ps:
CONTAINER ID | IMAGE | COMMAND | CREATED | STATUS | PORTS | NAMES
388a7219da3d | mongo:latest | "docker-entrypoint.s…" | About an hour ago | Up About an hour | 0.0.0.0:27017->27017/tcp, :::27017->27017/tcp | auction-mongodb
my schema.prisma:
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["mongodb"]
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
model Test {
id String @id @default(auto()) @map("_id") @db.ObjectId
text String
}
.env:
DATABASE_URL=mongodb://auction-user:password@localhost:27017/auction-db?authSource=admin
2
Answers
Simply add
?authSource=admin
to the end of your DATABASE_URL in.env
file.in my case this code solved.
user and pw suppose to have root role.
do remove +rsv if you want to connect to your local mongodb