Report this

What is the reason for this report?

Error establishing database connection

Posted on June 7, 2021

Hi I have installed my WordPress in Digital ocean. when I tried to open my website (which is under development) the following error is displayed “Error establishing database connection”. i got my domain name from godaddy. What should i do to resolve this issue…



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

Hi there @chandrandivya90,

It sounds like that your MySQL service might not be up and running. In order to start it you need to first SSH to your Droplet as per the instructions here:

https://docs.digitalocean.com/products/droplets/how-to/connect-with-ssh/

After that try to start the MySQL service:

systemctl start mysql

Let me know how it goes! Regards, Bobby

Hello, @chandrandivya90

First, you can ensure that the MySQL service is up and running:

  1. sudo systemctl status MySQL

You can double-check the database credentials in the wp-config.php file and make sure that they are added correctly in the file, e.g no blank spaces or typos.

It’s worth attempting to connect to the database from the command line, just to make sure. Copy and paste the details right from the config file into the following command:

  1. mysqlshow -u database_username -p

You’ll be prompted for a password. Paste it in and press ENTER. If you get an Access denied error, your username or password is incorrect.

You can also double-check the site files/folders permissions and ownerships. to set the correct permissions on the WordPress directories and files:

sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;

Another thing to check is the salt and key values in the wp-config.php file. More information can be found in our tutorial here:

https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-20-04-with-a-lamp-stack

Hope that this helps! Regards, Alex

The developer cloud

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

Start building today

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