Can't connect to MySQL

I am unable to complete installation on my VPS due to the following error:

Unable to connect to MySQL!

Unable to establish a connection to any database host (while trying “phabricator_config”). All masters and replicas are completely unreachable.

Make sure Phabricator and MySQL are correctly configured.

Every other app on my server (WordPress, phpMyAdmin) can connect just fine. I can even connect via CLI with the credentials I’ve configured Phabricator with.
MySQL is running on localhost, port 3306.

But this command worked: ./bin/storage upgrade --user root --pass xxxx --force

How did you install Phabricator? Is this a shared host?

This doesn’t really validate anything. Passing in the user and pass bypass the stored values. Phabricator uses both cli and web PHP, and you’ll need to check both work as expected. Did you run a normal ./bin/storage upgrade ? Does it work?

I did say it’s a VPS.
I just followed the installation and configuration guides, with a few caveats: I didn’t install APC because I couldn’t (it’s been dead and EOL for some time now), and the .htaccess config in the guide didn’t work right, so it took me a while to find a way to write it that would work.
I do have all of the necessary dependencies installed.

It didn’t. Turns out the db user I created didn’t have the right permissions.

Would have been nice if the error was more specific. It made it look like it didn’t even see MySQL running at all.

I am facing the same issue in my installation. It is a new VM(CentOS7) and all the required packages were installed with the shell script provided. I’m able to login and perform all action with the user created. But it is not working with Phab. I tried remote as well as local database instances, ./bin/storage upgrade is also working.

Any help would be much appreciated