You wake up to a database connection error. You check the MySQL logs: no errors, the service just stopped cleanly. Why? Because when RAM fills up, Linux's OOM (Out of Memory) killer kicks in and ruthlessly murders the process eating the most RAM—which is almost always MySQL.

The Fix: We need to tell Linux to never touch MySQL, even if it runs out of memory.

  1. Override the service file: systemctl edit mysql (or mariadb)

  2. Paste this into the editor:

Ini, TOML
 
[Service]
OOMScoreAdjust=-1000
  1. Save, exit, and reload the daemon:

Bash
 
systemctl daemon-reload
systemctl restart mysql

Now MySQL survives no matter what. Linux will just go kill something else instead (probably PHP).

🤔

Was this answer helpful?

Görüşünüz bizim için değerli!