vercel-community / php

🐘 PHP Runtime for ▲ Vercel Serverless Functions (support 7.4-8.3)

Home Page:https://php.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Access denied for user

varunsingh87 opened this issue · comments

Bug report

Description

Using the vercel-php runtime, I deployed my API on GoDaddy's domain but through Vercel's servers. As it is an API, I am trying to connect to one of my GoDaddy MySQL databases. I get the following error:

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'secondissea'@'ec2-13-57-11-140.us-west-1.compute.amazonaws.com' (using password: YES) in ------------

'secondisea' is my database username, and this works locally, because I whitelisted on GoDaddy. After the '@' I am using is Vercel's hosting server. And this entire thing is a PHP error when I am trying to connect to the database.

How do I get rid of this error? Since vercel-php is made for API endpoints, there has to be a solution.

NOTE: This works locally and by deploying on GoDaddy's hosting, but I need to deploy through Vercel. I COULD upgrade my GoDaddy account and I would no longer need Vercel, but that shouldn't be necessary because isn't what I am trying to do the point of this repo?

Hey! Thanks for report. It looks like issue with credentials. Have you configured something special? I mean whitelist your localhost domain, ip or something like that? How do you set username/password in Vercel? Via secrets or hardcoded?

Hi,
Thanks for the response. I whitelisted my home IP address and connect to the database via secrets both locally and deployed

I also dobt think there's any way to connect because I am using a hosting service for the database, not a cloud service. This means it can't be connected to remotely, especially since Vercel has dynamic IP addresses. That's my guess

I have no problem to connect to MySQL/Redis/Mongo etc. But it must be accessible from public. It seems to me, it's not problem at vercel or vercel-php.

Is this correct?
DB_USER: A username for the database
DB_PASSWORD: The password for the user of the database
DB_HOST: The IP address for cPanel on GoDaddy?
DB_NAME: The name of the database?

I don't know, it depends on your setup/framework/app.

But you're sure that there's no need to whitelist Vercel's IP address?

I solved by whitelisting all IPs (%.%.%.%)

Excellent. Thanks for update. 👍