0

MySQL works correctly on my server for several days. But all of a sudden, it stops working and my PHP application cannot connect to it anymore. The solution is easy: start/restart the MySQL service. However, it is a problem because my PHP application becomes unreliable if the MySQL service will suddenly stop working. Any ideas about what the root cause of this may be? When MySQL is down and I check the status, this is what I get:

root@jaimemontoya:~# systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2023-07-26 17:24:51 UTC; 1 day 19h ago
  Process: 11197 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
  Process: 11176 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 15388 (code=killed, signal=KILL)

Jul 26 17:24:51 jaimemontoya systemd[1]: mysql.service: Control process exited, code=exited status=1
Jul 26 17:24:51 jaimemontoya systemd[1]: mysql.service: Failed with result 'exit-code'.
Jul 26 17:24:51 jaimemontoya systemd[1]: Failed to start MySQL Community Server.
Jul 26 17:24:51 jaimemontoya systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jul 26 17:24:51 jaimemontoya systemd[1]: mysql.service: Scheduled restart job, restart counter is at 6.
Jul 26 17:24:51 jaimemontoya systemd[1]: Stopped MySQL Community Server.
Jul 26 17:24:51 jaimemontoya systemd[1]: mysql.service: Start request repeated too quickly.
Jul 26 17:24:51 jaimemontoya systemd[1]: mysql.service: Failed with result 'exit-code'.
Jul 26 17:24:51 jaimemontoya systemd[1]: Failed to start MySQL Community Server.

enter image description here

I am using Ubuntu 18.04.2 LTS:

root@jaimemontoya:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic

Maybe upgrading MySQL and/or Ubuntu could help to fix this issue?

As I said, the solution is simply restarting MySQL (see below) but I should not need to be manually restarting it after a few days, and MySQL should not suddenly stop working.

root@jaimemontoya:~# systemctl restart mysql.service
root@jaimemontoya:~# systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2023-07-28 14:37:58 UTC; 8s ago
  Process: 11668 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
  Process: 11647 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 11670 (mysqld)
    Tasks: 27 (limit: 1103)
   CGroup: /system.slice/mysql.service
           └─11670 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

enter image description here

1
  • 1
    They way I fixed this was to stop hosting my own databases. Such a risk. Now I rent a managed MySQL database cluster with full access from digital ocean and it stays online for years. Email & Database hosting is no joke. Let a data-center manage hardware, patch updates and uptime so that you can focus on actual coding.
    – suchislife
    Commented Jul 28, 2023 at 14:59

1 Answer 1

-1

As @suchislife suggested in his comment to my question, I followed his advice and rented a DigitalOcean MySQL Managed Database instead of the self-hosted database that I had on my DigitalOcean Droplet. I wrote my experience at https://jaimemontoya.com/blog/2023/10/17/23/21/ in terms of pricing when following the managed database route, emphasizing a comparison of the infrastructure as a service (IaaS) versus platform as a service (PaaS) models.

My conclusion: Self-hosted databases and/or mail servers is not advisable because of their inherent challenges.

2
  • Please add all relevant details that helped you to resolve the problem to your answer instead of posting links to external ressources
    – Nico Haase
    Commented Oct 18, 2023 at 11:47
  • Thank you @NicoHaase. I wish I had the solution to the real problem that I posted in my question. My answer implies that I could not find a solution and as a result, I followed the advice I received from a comment to my question, of renting a MySQL Managed Database instead of self-hosting databases. That also becomes my advise, which I stated in my conclusion. As an added bonus, I share my experience choosing between IaaS and PaaS, including pricing comparisons, when following the route of using the Managed Database approach. Commented Oct 18, 2023 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.