Good day,
While I was testing an application built with php and laravel that uses a mysql server installed on a digitalocean droplet of 1G ram, 1CPC, etc. The database suddenly crashed and was giving me the error: Job for mysql.service failed because the control process exited with error code. I actually tried to restore the database with another droplet using the same data directory but the error persisted and I discovered that the database might have been corrupted. Please I want to find out why the database suddenly crashed inside a droplet
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!
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.
Heya, @orstinoperri
This can happen due to misconfigured MySQL settings can lead to instability. You can use tools like MySQL Tunner to suggest recommended values. This article can help you on how to use the script:
https://www.digitalocean.com/community/questions/how-to-tweak-mysql-mariadb-configuration-for-increased-performance-and-stability
Another thing is to examine the MySQL logs to collect information about the error itself. Also the
/var/log/messages
can give information about the memory problems.The MySQL error logs can provide detailed information about why the service failed. The logs are typically located at
/var/log/mysql/error.log
or/var/log/mysqld.log
. To view the recent entries:Hope that this helps!
Heya @orstinoperri,
This sounds like your Droplet doesn’t have enough RAM to handle the processes thus killing them to avoid crashing itself.
There are usually 3 ways to go about this while I think only 2 out of the 3 ways will help you out in this situation.
First option (long term solution) - Upgrade your Droplet to have more RAM and CPU. That is the most certain way you’ll resolve the issue however, the other 2 options that I’ll present are needed for optimal execusion.
Second Option (short term if used alone) - Add SWAP to your Droplet. You can check this tutorial on how to achieve this - https://www.digitalocean.com/community/tutorial-collections/how-to-add-swap-space
Swap is a portion of hard drive storage that has been set aside for the operating system to temporarily store data that it can no longer hold in RAM. This lets you increase the amount of information that your server can keep in its working memory, with some caveats. The swap space on the hard drive will be used mainly when there is no longer sufficient space in RAM to hold in-use application data.
Third Option (should be considered always but is not enough on it’s own):
Optimize the Database and it’s performance. This is something you need to consider always however it will not be enough to save the DB from crashing it will help for a better performance. This however is a longer answer on what steps to take so I’ll post it separate to not clutter this one.
Hi there,
This sounds like either your server ran out of RAM or disk space.
It is best to check your server log and also MySQL logs at
/var/logs
. Feel free to share the errors that you get from the logs here so I can advise you further.There are a few things that you should make sure that you do:
Hope that this helps!
- Bobby