skip to Main Content

My question quiet long, cuz there a lot of thing I need:
I’ve built a Next.js App with Prisma, and created local mysql database with Xampp. Currently dev mode on my machine is working perfectly, but this is not why I built it.
Now I want to deploy it on vercel, but I don’t know how to connect it with mysql database (I already have a Shared hosting on namecheap).
Very confused;

  1. How to connect a remote mysql database with vercel on my app?
  2. How to deploy Next App with Prisma and Mysql on Cpanel?

Tried to deploy on vercel, but then got this error Can't reach database server at localhost:3306“. It meant I need to connect with a remote databse I believe.

2

Answers


  1. I created a full installer bash file that installs everything you need on VPS even SSL on NginX. If you want to deploy your project on Vercel, you cannot install mysql on it, but you can create a mysql on the PlanetScale and since it with your project with a simple connection.

    |___> VPS installer link

    Login or Signup to reply.
  2. You Will need to update your Database connection string with the details for your DB on your namecheap server.

    In your case it should be similar to:

    mysql://[DB User]:[DB Password]@[Namecheap Server IP]:[Port]/[DB Name]

    Additionally, Vercel uses a dynamic IP (for purposes like scaling etc), so your shared server will need to have port :3306 exposed publicly to allow a remote database connection from your Vercel deployment.

    If your shared server does not expose :3306 publicly, I have recently been looking at railway.app which will deploy i a similar manner to Vercel but also allows you to host your DB there too! Their starter plan is mega cheap at $5 month. So this might be a consideration if Vercel does not work out for you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search