New install of phpMyAdmin giving mysqli::real_connect(): (HY000/2002): No such file or directory

I used composer to install the latest version of phpMyAdmin and ran the setup. The setup acted oddly but it seems to have worked correctly. When I go to login, I get this error

mysqli::real_connect(): (HY000/2002): No such file or directory

I’ve tried everything I know. I need some help.

StackOverflow suggests that you may have the default ‘localhost’ in your config. Have you tried editing your config with a text editor to confirm that the host value is a fully qualified domain name or IP address?

I checked the config. It has ‘host’ set to however, I did find the ‘user’ was set to “root” so I changed it to the database user name. It sill gives the same error when I try to start phpMyAdmin in the browser.

I get the login page, enter the db name and password, click submit and get the login page back with
Cannot log in to the MySQL server
mysqli::real_connect(): (HY000/2006): MySQL server has gone away

So I tried setting up a test phpMyAdmin instance to reproduce the error, and I see the same error, but after spending a bit of time debugging, I feel I have to recommend what @dls mentioned to you in our Slack, which is that if you use an ssh tunnel, “You can use a local client like MySQL Workbench or HeidiSQL to access the database directly.”

To translate from the blog I linked above to your case, the “bastion” host would be login.ibiblio, and the “rds” host would be mysql.ibiblio.

I’m recommending this approach for two reasons. The first is that we do best-effort to support public webapps, but phpMyAdmin can never be for public consumption. It has to be restricted. Second is that even when restricted, phpMyAdmin has a pretty terrible track record in terms of security, and ibiblio in particular has seen instances of phpMyAdmin getting abused.

In closing, if you’re particularly attached to phpMyAdmin, it may even be possible to combine the ssh tunnel method and phpMyAdmin installed locally to you, but I would start with the simplest possible setup first.

I should add a couple of things that I failed to mention, @saturnfive. One is that the link on SSH tunneling that @dls shared was this one, which shows various platforms you might have as your workstation. The other is that the apache vhost you’re working with is served up by a cluster of machines behind a load balancer, haproxy, and I see this blog post, which suggests you need something like this in your file:

$cfg['PmaAbsoluteUri'] = '';

with swapped for your domain.

I’d just like to reiterate, however, that we need you to, at a minimum, lock down any phpMyAdmin you set up with a .htaccess file, or ideally remove the phpMyAdmin (for example by moving the directory outside your docroot) any time you’re not using it. As a bonus, you could name the directory something other than phpMyAdmin, since crawlers that find that tend to jump straight to abusive probing.

I understand your concerns about phpMyAdmin and security. We have it behind simple auth acccess, so its not public. I much prefer using a desktop app like MySQLWorkbench. I’ll give it a try.

I tried setting up the tunnel in PuTTY according to the article, but I can’t get in. Any suggestions?

What error are you getting? If you’re not seeing an error, is there a way to turn up the verbosity/logging on your application so you can get an error to share with us? Similarly, you may be able to turn up the verbosity/logging in PuTTY to see if that gives you more to work with.

A terminal opens up, blank, the title says after a while an error says the connection timed out.