-
QuestionWhy I am getting this error, PrismaClientInitializationError? I am currently learning Nextjs. During the course, I need to connect MySQL with NextJs through Prisma. I have followed all the steps one by one. But whenever I try to call the api I get this error.
Even though Prisma Studio is working just fine, How to reproduce (optional)Expected behavior (optional)No response Information about Prisma Schema, Client Queries and Environment (optional)// Add your schema.prisma // Add any relevant Prisma Client queries here
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @sheri0441 👋 Thank you for raising this question. According to the error message, Prisma Client is unable to establish a connection to your database because the username, password, or other connection details are incorrect. Can you double-check your .env file or wherever you are storing your database credentials to ensure that the username ( It might also interest you to know that if you use If this answers your question, it would be great if you could mark this Discussion as answered to indicate that it has been resolved. Otherwise please let us know how else we can help you further or close the Discussion if it was resolved in some other way 🙏 |
Beta Was this translation helpful? Give feedback.
-
Hey @sheri0441 👋
Out of curiosity, which course are you following to learn about Next.js and Prisma? |
Beta Was this translation helpful? Give feedback.
-
i have same issue but i uses supabase as a backent npx migrate is working and my schema stored in database at supabase but prisma client error is comming const prismaClientSingleton = () => { declare global { const prisma = globalThis.prismaGlobal ?? prismaClientSingleton(); export default prisma; if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma; |
Beta Was this translation helpful? Give feedback.
Hi @sheri0441 👋
Thank you for raising this question.
According to the error message, Prisma Client is unable to establish a connection to your database because the username, password, or other connection details are incorrect. Can you double-check your .env file or wherever you are storing your database credentials to ensure that the username (
root
in your case) and password are correct. If you've recently changed your database password or other connection details, you may need to regenerate the Prisma client by runningnpx prisma generate
.It might also interest you to know that if you use
$
symbol as part of your password in your .env file, you will need to escape it with\
. i.e\$
. See…