Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Per DigitalOcean’s How To Debug the WordPress “Error Establishing Database Connection”, I have followed the steps to attempt to resolve the issue stated in the title of my question. Unfortunately, I’m still encountering the error and, importantly, it is not intermittent, so I do not believe it is a memory issue. For context as to when this issue began, please refer to the note at the bottom.
Droplet: Regular 1GB / 1 CPU Ubuntu 22.04
Potential issue: I’ve just updated from 20.04 to 22.04. On my DigitalOcean dashboard, my droplet is still showing LAMP on Ubuntu 20.04, though I’m not sure that was ever going to update.
App: WordPress
On the primary URL of my WordPress site, I’m only seeing an index of the files. At the bottom, its says:
Apache/2.4.52 (Ubuntu) Server at [domain] Port 443
User Sergiu Dumitriu on Stack Overflow suggested that a user with a similar (but intermittently problematic) situation ensure the if the default port for MySQL is different than the default 3306 to change it in wp-config.php. I have not had a chance to test this, but I don’t believe 443 corresponds to the MySQL port.
At /wp-admin, I see the following message:
Cannot select database
The database server could be connected to (which means your username and password is okay) but the
[database-name]database could not be selected.
- Are you sure it exists?
- Does the
[database-user]have permission to use the[database-name]database?- On some systems the name of your database is prefixed with your username, so it would be like
[database-user]_[database-name]. Could that be the problem?
I have verified all of these scenarios are not the culprit by following this DigitalOcean guide. I get the titular “Error establishing database connection” when I attempt to repair the database as outlined in Repairing the WordPress Database.
User DriftingBlueCoral suggested repairing the MySQL tables with the command:
/usr/bin/mysqlcheck --all-databases --auto-repair
I attempted to run this, but received the following error:
Access denied for user 'root'@'localhost' (using password: NO) when trying to connect
I’m not very familiar with Apache and MySQL, so I’m not sure how I can both run this command and use my root user’s password, since that would mean logging into MySQL and relying on MySQL commands.
My personal portfolio and this WordPress site are siblings on my server. I was uploading files via FTP and accidentally deleted the entire folder for my WordPress site. I attempted to cancel the process, but it had already wiped crucial files for the operation of the site.
I did not perform routine backups. I will now be performing routine backups.
Following DigitalOcean’s How To Install WordPress on Ubuntu 20.04 with a LAMP Stack that got me up and running the first time, I’ve arrived here. I’m confident the issue is some kind of misalignment with my tables.
For instance, would the original database and user have been deleted with WordPress files? Again, I’m new to MySQL, but I don’t believe that is how it’s structured. Are the original database and user conflicting with the ones I have created following the guide? I feel like this is where my problem lies, but I simply am not sure, and am hopeful the community can lend me a hand.
Thank you.
hbarnard
keneucker
keneucker
rich
santoshpatil
Aspiresoftserv
Yakin
Thejaswini-Rao-U
775c69c916d345a7a367d867078ccb
mayricoak
ndam
bc2f52583874402a988f587c00195d