Error connection database 😑

Hello friends!

Every day I receive alerts of this error "Error connection database"
I do not know what might be causing this, someone would know how to solve this problem definitively.

Thanks for any help!

You probably need to provide a lot more information to get a useful answer on this one :slight_smile: (e.g. when/how is this happening, where are you seeing the message, only on one domain or all domains, what kind of load is the server under etc)

  • WordPress updated
  • Easy Engine
  • CPU: 1vCore
  • RAM: 1024 MB
  • Bandwidth: 1000 GB
  • OS: Ubuntu 14.04 x64
  • Host: Vultr

I have only one site running on this server I get around 700-900 visits per day Page Views Monthly between 70 and 90 thousand I’m using CloudFlare

Pingdom alert. When I go to check the site is with the white screen with this warning. To resolve I have to go to ssh and use the service mysql restart command to get everything back to normal.

Hello, you server is probably running out of RAM, 1GB is the minimum for EasyEngine stacks. Take a look on memory usage with htop

apt install htop -y

htop

Here is a recorded screen!

Try this: https://easyengine.io/docs/prevent-mysql-crashing/

1 Like

I’ll check, thank you!

I had that problem also. I haven’t tried tuning MySQL yet, but when this happens you can easily restart MySQL with this command:

sudo service mysql start

Also, I set up a cron job that runs a script every minute to check to be sure MySQL is running; if it’s not running, not, the script starts it. I made a file in the /root directory called mysqlfix.sh. Contents:

#!/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
if [[ ! "$(/usr/sbin/service mysql status)" =~ "(running)" ]]
then
    echo "MySQL was just restarted on your server." | mail -s "MySQL restarted" -a "From: my-server-name <[email protected]>" [email protected]
sudo service mysql start
fi

and then you have to add a cron job. To do that, type sudo crontab -e and add this line:

*/1 * * * * /root/mysqlfix.sh

The script also sends an email to the address you specify to let you know it restarted MySQL. Make sure you test it carefully because it will be sending emails every minute if you misconfigure it. If anyone sees any risks or problems with this method, please let me know. Thanks!

Hope that helps!

2 Likes