Prisma InvalidDatasourceError: Error validating datasource db: the URL must start with the protocol prisma://

411 Views Asked by At

Question: I'm encountering an issue with Prisma where I get the error message "InvalidDatasourceError: Error validating datasource db: the URL must start with the protocol prisma://" when running bun dev. Here are the details of my setup:

Environment: Bun Elysia Prisma MySQL

"DATABASE_URL="mysql://root:password@localhost:3306/MyTodoApp"

//schema.prisma:


generator client {
  provider = "prisma-client-js"
  binaryTargets = ["native", "debian-openssl-3.0.x"]
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

Every time I run bun dev, I encounter this error. However, when I follow the error message's suggestion to add an API key, I can't find any relevant information in the Prisma documentation.

Can anyone help me understand why I'm getting this error and how to resolve it? Thank you!

1

There are 1 best solutions below

2
Ebubekir Güngör On

did you try writing the url directly like this:

datasource db {
  provider = "mysql"
  url      = "mysql://root:password@localhost:3306/MyTodoApp"
}

If still there is an error, can you share your whole .env file?