在NestJs+Prisma项目的终端中运行npx prisma db push
命令时,出现以下身份验证错误
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": MongoDB database "test" at "localhost:27017"
Error: MongoDB error
SCRAM failure: Authentication failed.
0: schema_core::commands::schema_push::Calculate `from`
at schema-engine/core/src/commands/schema_push.rs:29
1: schema_core::state::SchemaPush
at schema-engine/core/src/state.rs:432
字符串
我正在使用Prisma连接mongodb,使用以下代码
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
model User {
id String @id @default(uuid()) @map("_id")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
emailId String
@@index([emailID])
}
型.env
文件中的数据库字符串是
// DB Name is test
DATABASE_URL="mongodb://user:password@localhost:27017/test?authMechanism=SCRAM-SHA-1"
型
我正在使用以下版本的Prisma & Prisma-Client
"@prisma/client": "^5.0.0",
"prisma": "^5.0.0",
型
1条答案
按热度按时间ymdaylpp1#
将
authSource=admin
添加到URL参数。新的URL应该是这样的:字符串