Every server has a limited amount of memory, also known as RAM. The amount of memory your server has is determined by the type of server you're paying for at your server provider.
When a server runs out of memory, the server must kill processes so the server can keep running. This is the most common cause of MySQL crashing: the server ran out of memory and had to kill MySQL.
The best solution to running out of memory is to upgrade to a server with more memory.
The mount of memory your server uses is related to many factors, including
The operating system and core services use around 150MB of memory.
Each simple app (small codebase, one database, low traffic) uses about 50MB of memory.
So, for example, with 10 apps your server would normally use about 650MB of memory. That is,
150MB (OS memory usage) + 10 (number apps) * 50MB (app memory usage) = 650MB
If you need to lower memory usage, you can do a few things to save memory.
Each new version of PHP includes optimizations that reduce that amount of memory used internally by PHP to execute your scripts.
You should use the newest version of PHP that your app supports.
Disable any WordPress plugins that you don't need.
Some WordPress plugins increase memory usage significantly. By disabling plugins you don't need, you can save memory.
If you've added third-party PHP extensions like New Relic, these will increase memory usage.
If you need these extensions, you should not disable them. However, if you've added them and aren't using them anymore, you should disable them.
PHP has a built-in opcache that is enabled by default.
The entire purpose of PHP's opcache is to speed up your scripts and save CPU by storing compiled PHP scripts in memory.
If you'd rather to have slower apps and increased CPU usage to save memory, you can disable the opcache.
Learn how to disable the PHP opcache.