systemctl start mariadb hangs, then fails with a timeout
Job for mariadb.service failed because a timeout was exceeded.Short answer
When mariadb.service fails or hangs, the journal and the server's own start-up messages say why. The default start timeout is about 90 seconds, so long crash recovery gets killed by systemd. Raise TimeoutStartSec with a drop-in file, or fix the real fault in the log: corrupt InnoDB pages or a damaged Aria control file.
Fix it fast
1Find out which cause you have
Read the service status and the last journal lines before changing anything. The wording tells a timeout apart from a crash at start-up.
sudo systemctl status mariadb.service sudo journalctl -n 50 -u mariadb.service2Match what you see, then jump to its fix
- 1
mariadb.service start-pre operation timed out. Terminating.Crash recovery takes longer than the systemd start timeoutFix - 2
The log shows InnoDB page corruption or a failed recovery, and the server exits instead of just taking longInnoDB cannot recover because pages or the redo log are corruptFix - 3
Missing valid id in the aria control file, in the journalAria control file or log files are corruptFix
- 1
What does the error look like?
Job for mariadb.service failed because a timeout was exceeded.mariadb.service start-pre operation timed out. Terminating.Failed to start MariaDB 11.4 database server.
Cause 1 of 3
Crash recovery takes longer than the systemd start timeout
1Check
The unit has a start timeout of about 90 seconds. After a crash or a kill, InnoDB recovery of a large redo log can take longer. The journal shows recovery messages right before the timeout.
sudo journalctl -u mariadb.service | grep -i -E 'recover|timed out'2Fix
Give the unit an unlimited start timeout in a drop-in file, then reload systemd and start again. With systemd 236 or later, MariaDB can extend the timeout itself, so check the version first.
sudo systemctl edit mariadb.service
# in the editor add:
[Service]
TimeoutStartSec=infinity
TimeoutStopSec=infinity
sudo systemctl daemon-reload
sudo systemctl start mariadb.service3Verify
The unit becomes active (running).
systemctl --version | head -1 && systemctl is-active mariadb.serviceConfirmed by mariadb.com
Cause 2 of 3
InnoDB cannot recover because pages or the redo log are corrupt
1Check
Read the error log for lines mentioning InnoDB corruption. Copy the data directory before any recovery step.
sudo journalctl -u mariadb.service | grep -i innodb | tail -n 302Fix
Start with innodb_force_recovery=1 and go up one level at a time only if needed. This mode is read-only emergency access, not a repair: dump the data, then rebuild the instance from the dump.
# /etc/mysql/mariadb.conf.d/99-recovery.cnf
[mysqld]
innodb_force_recovery = 1
sudo systemctl start mariadb
sudo mariadb-dump --all-databases > rescue.sql3Verify
The server stays up and the dump completes. Remove the setting once the data is restored.
ls -lh rescue.sqlConfirmed by mariadb.com
Cause 3 of 3
Aria control file or log files are corrupt
1Check
This message means something overwrote at least the first bytes of the Aria control file.
sudo journalctl -u mariadb.service | grep -i aria2Fix
With the server stopped, move the aria_log_control file and the aria_log files away. Aria then checks and repairs its tables when they are next opened.
sudo mkdir /root/aria-backup
sudo mv /var/lib/mysql/aria_log_control /var/lib/mysql/aria_log.* /root/aria-backup/
sudo systemctl start mariadb.service3Verify
The service starts and the journal has no Aria errors.
systemctl is-active mariadb.serviceConfirmed by mariadb.com
How do I stop it coming back?
- Shut the server down with systemctl stop, never by killing the process, so the next start needs little recovery.
- Keep the data disk from filling up; a full disk is a common reason for corruption.
- Back up with mariadb-backup or a dump on a schedule and test the restore.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
An Aria table fails with 'Read page with wrong checksum' (error 1030, code 176)
ERROR 1030 (HY000): Got error 176 "Read page with wrong checksum" from storage engine Aria
Code 176 means MariaDB's Aria engine read a data or index page whose checksum does not match, so that table file is damaged.
3 causes, each with a fixDatabases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
An EC2 instance cannot reach its RDS database
Could not open connection to the host, on port <port>: Connect failed
RDS denies all access until a security group allows it.
3 causes, each with a fixDatabases
Locked out of a fresh MariaDB install as root on Mac or Linux
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
A fresh MariaDB root account is not a normal password account.
3 causes, each with a fixDatabases
The client cannot open a TCP connection to MariaDB or MySQL (error 2003)
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (111)
Error 2003 means the client tried a TCP connection to the host and port and nobody answered.
4 causes, each with a fix