How to Check MySQL Startup Time and Common Causes of MySQL Crashes
This article explains four methods to determine MySQL server startup time, such as checking service status, querying uptime, using ps, and inspecting logs, and also outlines common crash causes like bugs and resource allocation failures, providing troubleshooting steps and diagnostic commands.
The article describes how to detect when a MySQL instance was started and lists the most frequent reasons for MySQL crashes, offering concrete commands and diagnostic tips.
Check MySQL Service Status
Run service mysql status to view the service state and the time since it has been running.
scutech@scutech:~$ service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-10-21 05:54:18 NDT; 4 days ago
Process: 774 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
Process: 708 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 791 (mysqld)
Tasks: 27 (limit: 2328)
CGroup: /system.slice/mysql.service
└─791 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pidCheck MySQL Uptime Variable
Execute show global status like 'uptime'; to obtain the uptime in seconds, then convert it to days.
mysql> show global status like 'uptime';
+---------------+--------+
| Variable_name | Value |
+---------------+--------+
| Uptime | 428334 |
+---------------+--------+
1 row in set (0.32 sec)Convert seconds to days:
mysql> select 428334/60/60/24;
+-----------------+
| 428334/60/60/24 |
+-----------------+
| 4.957569444444 |
+-----------------+
1 row in set (0.01 sec)Use ps to Inspect Process Start Time
Run ps -eo pid,user,args,etime | grep mysqld to see the elapsed time since the mysqld process began.
scutech@scutech:~$ ps -eo pid,user,args,etime | grep mysqld
791 mysql /usr/sbin/mysqld --daemoniz 4-23:03:54Check MySQL Log for Startup Message
Search the error log for the phrase “ready for connections” to locate the exact startup timestamp.
2020-10-21T08:24:18.986765Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.28-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)Common Causes of MySQL Crashes
The two most frequent reasons are bugs in MySQL itself and failures to acquire necessary system resources.
MySQL Bugs
Most bugs are triggered by specific SQL statements; enable the general query log to identify the last statement before a crash, then consult the MySQL bug database and upgrade to a version where the bug is fixed.
System Resource Allocation Failures
Insufficient memory or disk space can cause mysqld to receive signal 11. The error log will contain messages such as “mysqld got signal 11”. Use perror 11 to interpret the OS error, and adjust configuration parameters like max_connections or buffer sizes accordingly.
root@scutech:~# perror 11
OS error code 11: Resource temporarily unavailable
MySQL error code MY-000011: Can't unlock file (OS errno %d - %s) 10:55:07 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
...Additional troubleshooting steps include carefully reading the error log, opening the general query log to examine the last accessed table or index, enabling core dumps and analyzing them with gdb, tracing system calls with strace, or recompiling mysqld with debug options.
Full-Stack Internet Architecture
Introducing full-stack Internet architecture technologies centered on Java
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.