25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Digitalocean – MySQL keeps crashing – Here’s how to fix it!

by | Dec 12, 2018

Does your website often show “Error establishing a database connection” message ?

If the answer is Yes, a possible reason could be MySQL service crash on your DigitalOcean Droplet.

Usually, the exact reason for MySQL crash varies from lack of resources on the server to bad website scripts.

At Bobcares, we help customers to fix MySQL service in droplets as part of our Dedicated Support Services for Web Hosts.

Today, we’ll see the common reasons that cause MySQL crashing and how we fix them.

 

Reasons for MySQL crashing in DigitalOcean Droplet

A MySQL server crash is really critical because all your websites will be affected by this. Therefore, it needs a quick solution.

For this, we first need to find out the reason for MySQL failure.

Let’s have a look at the various reasons that would crash the MySQL service on the Droplet.

 

1. Buggy scripts

From our experience in managing DO Droplets, we often see buggy php scripts overloading the server. These scripts have bad mysql queries that would consume server resources. Additionally, they just keep on running on the server without giving a result.

Similarly, in WordPress websites, often certain plugins cause MySQL to fail. And that causes database errors on the website.

 

2. Lack of server resources

Yet another reason for MySQL crash could be lack of server resources.

This happens mainly when the minimal configuration Droplets provided by Digital Ocean are stuffed with too many websites. These Droplets would have only a total 512MB memory. This low memory will not be enough to handle high traffic websites, manage server processes, etc. As a result, it results in ‘Out of Memory’ issues in droplet.

When the physical memory (RAM) is full, PHP scripts use a buffer memory called “Swap” to process the request. If we plan to use this buffer space, we need to assign this Swap space during the initial set up of Droplet.

When adequate swap space is not created in the Droplet, lack of memory can again lead to MySQL crash.

 

3. Malicious attacks

Occasionally, the high resource usage by MySQL would not be due to valid website access. We often see that attacks involving xmlrpc.php file of WordPress. In this attack, hacker tries to break into the admin panel of WordPress using too many hits to the website.

The server eventually will not be able to handle the large number of requests and can crash.

 

4. Broken databases

Similarly, broken databases also can cause Database errors in the Website. This happens mainly when the database files becomes corrupt. Often, disk full issues, permission problems can also lead to MySQL crash.

 

How to fix MySQL crashing in DigitalOcean Droplets?

We’ve now seen the various reasons that would crash MySQL on your Droplet.

Now, let’s see how our Support Engineers resolve these MySQL crash on Droplets. Depending on the reason for crash, the fix also varies. Let’s see these fixes in detail.

 

1. Allocate adequate server resources

This involves allocating adequate amount of resources on the droplet. Again, this largely depends on the functionality of the server. The Droplet should have enough processing power, memory, swap space, disk space, etc. on the server.

By default, the DigitalOcean Droplets do not have swap space created. Here, our Hosting Support Experts analyze the resources on the server and reserve adequate percentage of memory for swap. For example, in a Droplet with 4GB memory, depending on the type of websites, a swap space of 1GB would be ideal.

However, if there is consistent use of swap space on the server, we advise customers to permanently upgrade the memory of Droplet.

 

2. Service optimization

Even though there is enough resources on the server, wrong MySQL configuration often cause crash. That’s why, on a Droplet with frequent MySQL crash, our Security Engineers enable slow queries in MySQL. And, it will be logged to the mysql log file available at /var/log/mysql/log-slow-queries.log. This helps us to identify the specific sites that cause the problem.

If the problem is with the website script, we help website owners to fix it. This applies to the trouble causing plugins in WordPress websites as well.

Additionally, we optimize the MySQL service variables like max_connections, query_cache_limit, table_cache, etc.

For the best results, we extend this optimization to the web server too. This involves changes like restricting values such as  Max_clients, StartServers in Apache configuration, choosing the correct processing module, etc.

 

3. Prevent malicious attacks

When we see an attack on a Droplet, we implement proper firewall to protect these malicious attacks. For instance, in xmlrpc attack, we disable xmlrpc method on the server as a whole, install plugins to stop attack, etc.

Additionally, our Security Experts suggest customers to proactively set proper defending mechanisms in the Droplets.

 

4. Periodic Database Check

It is worth to do a periodic check of the databases running on the server. This would help us to track and repair corrupt tables if any. Our Expert Engineers do a scheduled database check with the help of cron jobs. This includes a check of the server disk space usage, MySQL log file size, etc. as well. Thus, we can omit the MySQL crash due to disk full issues.

 

Conclusion

MySQL crashing in DigitalOcean Droplets happen mainly due to scarcity of resources, bad MySQL configuration, buggy scripts, etc. Today, we’ve seen how our Support Engineers analyze the database server crash and fix it.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

SEE SERVER ADMIN PLANS

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF