0

so I have a few WordPress sites installed on my LAMP Ubuntu server. The past couple of days things have been extremely slow.. I am able to login to the wp-admin of my websites but from there any request (e.g. themes or new post) is followed by a 46 second wait time and then the error "Can’t select database" If I go to another one of my websites I get the same thing..

I can log into the back-end so I know it isn't my password that is causing this.. My server says mysql is running as well..

If I try and go back to one of these sites after that error above I get another error "Error establishing a database connection" Which is resolved by running

service mysql restart

However once I do this the cycle restarts.. Slow load time, "Can’t select database", mysql restart, and so on..

Any help would be greatly appreciated. Thank you in advance!

UPDATE: Rather than run service mysql restart. If I wait about 5 minutes after receiving either error everything seems to be up again (until I try and go somewhere in wp-admin then it crashes again.)

1 Answer 1

0

Try a plugin like Query Monitor to see if there are queries or things you can identify quickly. A DB may need a log rotated or you could have some DEBUG process turned on that is logging. Backups running on your server will also have an impact. It's something you'll have to look into. Same with crons, virus scanners and any other bulk process.

If you have too many connections then you can create a DB bottleneck. Check your pages and process that you aren't using an excessive amount of queries when they could be reduced. Also make sure to use functions that cache queries when possible.

Some good info at https://10up.github.io/Engineering-Best-Practices/php/#performance is worth looking into.

Also try connecting to your DB to see what is happening. Running EXPLAIN can tell you more about slow queries. https://dev.mysql.com/downloads/workbench/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.