Wordpress - Error establishing a database connection

Ubuntu Linux 22.04.3

Virtualmin version 7.20.2

My motherboard died but I was able to get same model. I had 17 virtual servers and
managed to restore all of them except for the wordpress virtual server.

All the folder and files for wordpress are there directly inside the “Public” folder not the wordpress subdirectory.

wp-config.php
define(‘DB_NAME’, ‘mywebsite_wordpress’);

MySql database has them under sub-directory “mywebsite_wordpress.”
/home/testsite/public_html/wordpress

Seems like everything is pointing to a sub-directory but it seems to be installed at the top level not a sub-directory.

Thanks
ettie

I’m not sure a path issue would cause a database connection issue.
Turn on debug, you may get more feedback.

Yeah, I think you’re mixing up problems here.

This is the web root, and has nothing to do with the database.

The database lives in the Mariadb data directory (which is probably in /var/lib/mariadb or similar). But, if you’re trying to mess with that, you’re definitely doing something wrong. Database data directory is not something you should ever change.

You’re going to need to look at the log to see what’s actually going wrong.

Could be the PHP log, could be the error_log. You can also make sure the database is running and can be seen just by browsing to it. Just click on “Edit Databases”, and click the wordpress database name and make sure it has some tables and stuff.

Anyway, show us the actual error(s) from the log, and we can probably point you in the right direction.

It also happened to me, I did several checks and decided to open port 3306 in and out on the firewall.
Now it has normalized.

Thanks for the all the responses!. I will work on getting you some more info. It might be a few days because I work nights.
Thanks

Unless the database server is on another system, there is no reason to do anything with the firewall. A local database listening on the localhost address is always accessible to local clients. I would not recommend making the database accessible over the network unless you need remote access to the database (any app running locally on the server, including WordPress, does not need remote access to the database).

Securing a remotely accessible database is a lot more complicated.

1 Like

Although I was aware of it, I wanted to test if it would improve.
The IN and OUT port has already been removed.
I appreciate your observation.