Question

How to solve Mysql database connection error frequently after wordpress installation?

Recently I have purchased vps and after installing a website on wordpress frequenly I am getting an error about mysql database connection error. Each and every time I need to reboot my server, this is not feasible.

Show comments

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

The most common reason for this issue is that your MySQL process is exhausting the RAM your droplet has available. This then causes the service to crash. There are three steps you can take to resolve this:

1.) Set up a swap file on your droplet. This should prevent the crashes. 2.) Upgrade to a larger droplet with more RAM available. 3.) Optimize your MySQL and other services.

@ryanpq I just enabled a swapfile on one of my droplets. Since the error seems to occur randomly (not at times of high load) I’m not sure if doing this made a difference or not. Is there a way to stress test the effectiveness of an enabled swapfile? Thanks

@ryanpq why does this seem to be a continuous problem for wordpress installs on DO? I haven’t seen this issue across other hosts