I’m frustrated with the error below on running the command:
npx prisma migrate dev
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": MySQL database "nextapp" at "localhost:3306"
Error: P1001: Can't reach database server at `localhost`:`3306`
Please make sure your database server is running at `localhost`:`3306`.
I uninstalled and re-installed MySQL and Prisma to re-run the commands step-by-step in case I missed something but still the same error.
Can someone help?
I had the same problem as you today on my MacBook (Sonoma 14.0).
I think it’s because I also had MySql installed from my Terminal with Homebrew.
As a first step, I uninstalled MySql from System Settings (Uninstall at bottom right):
Then I followed this tutorial to clean up any MySql on my computer: Remove MySQL completely from Mac OSX · GitHub
After this big clean-up, I rebooted my computer and reinstalled MySql as explained in Mosh’s video, and it finally worked!
I hope this helps.
First of all, thank you for sparing time to reply on my issue.
I was wondering at zero replies so far from the community
As a Windows user, I had actually used a special software Revo-Uninstaller to find all MySQL files installed deep into the OS and then removed all those while uninstalling MySQL and then re-installed it.
But, I still faced the issue and it’s unresolved so far.
However, I will try to look for a similar repo/forum where anyone explained the uninstall similar to the one that you shared for MacOS.
Maybe, something works out.
I spared full 4 days in thoroughly searching the internet and then exhausted all debug options that ChatGPT asked me to but still this bug is not getting fixed.
So frustrating and big waste of time.
Now, I reached out to Prisma team and hoping something gets worked out. Let’s see.
However, thanks for providing pointers and I’ll retry.
Hi, Manu. Please try the below:
- Search for ‘services’ in the tool bar at the bottom
- Click on the ‘Services’ app with the gear icon.
- In the list of services search for ‘MySQL’ (there might be a number postfixed)
- Right click on MySQL and click start
- Run ‘npx prisma migrate dev’ in the terminal again
Hope its helpful
Thanks for sparing your time to answer. Appreciate it.
Actually, I did try that already while I was debugging and it did not help.
Honestly, I tried everything under the Sun that I could google or get to know from ChatGPT.
At 1 point, even ChatGPT ran out of options to help me
Finally, Prisma team suggested me to use PlanetScale’s managed SQL database and everything has been running smoothly since then.
It’s still an unresolved mystery why local db does not get connected. But, I have let it go