By Leora
I am following this tutorial for three WordPress sites: https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-20-04-with-a-lamp-stack
The first two were set up with no issues. The third, however, is in a subdirectory. I tested that there is a connection with mysql -u <DB_USER> -p<DB_PASSWORD> -h <DB_HOST> <DB_NAME> I also tested that it is reading my wp-config.php by adding die(“Loading this file now”); to the top. So it does display that line now. I also looked at How To Debug the WordPress “Error Establishing Database Connection” https://www.digitalocean.com/community/tutorials/how-to-debug-the-wordpress-error-establishing-database-connection but none of those suggestions helped.
I am thinking it is perhaps related to the fact that I putting WordPress in a subdirectory: mydomain.com/blog Maybe some permission issue?
Any ideas?
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!
Hello, @leorawe
Normally the best thing to do is to keep the currently installed. Would you mind listing all the available options that you get?
Regards, Alex
Hi @leorawe,
It’s possible there is a permissions issue. You need to make your Folders 755 and your Files 644 permissions.
Additionally, what I think it’s mostly possible is your Password being wrong, at least what you’ve typed in your wp.config.php. Another common thing that occurs is the password containing the single quote symbol - ’ which is not being interpreted as part of the password.
Hello, @leorawe
First, you can ensure that the MySQL service is up and running:
- 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:
- 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:
Hope that this helps! Regards, Alex
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.