Npx prisma migrate dev - failing

Hi Forum,

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?

Manu

Hi Manu,

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.

Best,
Rémi

Hi Remi,

First of all, thank you for sparing time to reply on my issue.

I was wondering at zero replies so far from the community :slight_smile:

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.

Manu

Hi, Manu. Please try the below:

  1. Search for ‘services’ in the tool bar at the bottom
  2. Click on the ‘Services’ app with the gear icon.
  3. In the list of services search for ‘MySQL’ (there might be a number postfixed)
  4. Right click on MySQL and click start
  5. Run ‘npx prisma migrate dev’ in the terminal again

Hope its helpful

Hi lucidlear,
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 :slight_smile:

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 :slight_smile:

Manu

hey,
Did you get the work around with this one. I am facing the same issue.

Installing a slightly older version of mysql (8.0.37) worked for me, like they did here Reddit - Dive into anything. The version 8.4.0 LTS doesn’t seem to work properly for me, it keeps turning on and off non stop if you check its status in system settings.

I am not sure if this is the solution to your problem. I have an M2 MAC and my problem was that the mySQL server instance started and stopped 2 seconds later, which is a known problem with mySQL 8.4. You need to unclick the keyring Data File.