Question

I have installed wordpress theme and I am getting an error.

Posted December 13, 2021 84 views
MySQLWordPress

I have installed wordpress theme and I am getting an error.
This is not a constant error. Error appears, then it appears as normal and repeats.

“error establishing a database connection”

Why? please check.

https://gyazo.com/0d797e1f896b250f31d7c4617807cfb6

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hello, @ssillookboy

Can you confirm if the MySQL service is running at the moment? To check run:

  • sudo systemctl status mysql

You can also check our article on How To Debug the WordPress “Error Establishing Database Connection

https://www.digitalocean.com/community/tutorials/how-to-debug-the-wordpress-error-establishing-database-connection

Regards,
Alex

by Brian Boucheron
WordPress is one of the most popular open source content management systems in the world. Although it started out focused on blogging, over the years it has developed into a more flexible platform for websites in general. After almost fifteen years of development it is quite polished and robust, yet issues can still come up. If you've recently attempted to load your WordPress-powered website and instead saw a message stating "Error Establishing Database Connection", the cause is most often...

Hi @ssillookboy,

Usually, when you experience such an error it’s related to your MySQL application. Most probably your MySQL is getting killed for some reason, either because it can’t handle the traffic or your Droplet is having high load.

When this happens I recommend SSHing to your Droplet and checking if MySQL is actually running.

sudo netstat -plt

The netstat command prints information about our server’s networking system. In this case, you want the names of programs (-p) listening for connections (-l) on a tcp socket (-t). Check the output for a line listing mysqld.

If you find it, you’ll know MySQL is running, if you don’t, then you can start it with:

systemctl start mysql

As mentioned for further debugging you can try and see:

https://www.digitalocean.com/community/tutorials/how-to-debug-the-wordpress-error-establishing-database-connection

Another thing you can try is to add SWAP to your Droplet. Swap is a portion of hard drive storage that has been set aside for the operating system to temporarily store data that it can no longer hold in RAM. This lets you increase the amount of information that your server can keep in its working memory, with some caveats. The swap space on the hard drive will be used mainly when there is no longer sufficient space in RAM to hold in-use application data.

https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04

by Brian Boucheron
WordPress is one of the most popular open source content management systems in the world. Although it started out focused on blogging, over the years it has developed into a more flexible platform for websites in general. After almost fifteen years of development it is quite polished and robust, yet issues can still come up. If you've recently attempted to load your WordPress-powered website and instead saw a message stating "Error Establishing Database Connection", the cause is most often...