Restore backup fails with "Error establishing a database connection"

I’m trying to migrate from one hosting provider running CentOS 5.5 to another running CentOS 72. I have four sites to migrate. One is running Joomla, one is static HTML, and two are running Wordpress. I have successfully migrated the Joomla site, the static site, and one of the Wordpress sites, but the other Wordpress site consistently throws off the error “Error establishing a database connection” on both the front and backend. I’ve checked the usual culprits (db name, username, password). I tried disabling the firewall on the off-chance that it was causing problems, but no love. I’ve tried restarting the Mariadb server. The logs don’t include any info. I’m at a loss and would really appreciate any insights. Thanks, in advance.

Howdy,

So just to clarify, other databases are working okay on this server, it’s just the one for this one domain that’s an issue?

What if you try accessing the database for that particular user from the command line, what happens in that case?

You can do that using this command:

mysql -u USERNAME -p DATABASENAME

Does that allow you to access the database in question?

-Eric

Yes, all other databases are working fine on this server. The only thing I’ve done after building the server was to install Virtualmin and restore the four site backups. The other three are working fine. It’s just this one which has been problematic.

I’m not able to access the database on the new server using the command line. The username, database name, and password are the same as the ones which are working on the original server. In fact, I tried accessing the database on the original server from the command line and it worked fine.

I’ve figured out the problem (with a head slap). Virtualmin backed up the wrong database. Now, I’m trying to figure out how to tell it which database is associated with the site in question.

The problem arose from a web developer creating a database outside of Virtualmin during an installation of Wordpress. Virtualmin did not associate the new database with the site and, when I ran the backup, it only backed up an older database which had a similar name. I imported the new database and ran the backup. When I restored the backup on the new server, I had to add the Wordpress database user, which, for some reason, was not included in the restore. After that, everything appeared to be fine.