Table of Contents
Problem
Yesterday, when I start the MariaDB on my server, I got the error below:
bonben@ub20:# systemctl start mariadb.service
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
The output when I ran the command systemctl status mariadb.service:
bonben@ub20:# systemctl status mariadb.service
● mariadb.service - MariaDB 10.3.34 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2022-11-24 08:25:40 UTC; 10min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 2071 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 2072 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 2074 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]
&& systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 2121 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
Main PID: 2121 (code=exited, status=1/FAILURE)
Status: "MariaDB server is down"
Nov 24 08:25:38 store systemd[1]: Starting MariaDB 10.3.34 database server...
Nov 24 08:25:38 store mysqld[2121]: 2022-11-24 8:25:38 0 [Note] /usr/sbin/mysqld (mysqld 10.3.34-MariaDB-0ubuntu0.20.04.1) starting as process 2121 ...
Nov 24 08:25:40 store systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Nov 24 08:25:40 store systemd[1]: mariadb.service: Failed with result 'exit-code'.
Nov 24 08:25:40 store systemd[1]: Failed to start MariaDB 10.3.34 database server.
Solution
The solution is deleting or renaming the tc.log file, this file is created automatically when the MariaDB server crashed.
You can use mlocate to find that file as follows. And as you can see, the file located in /var/lib/mysql.
bonben@ub20:# mlocate tc.log
/var/lib/mysql/tc.log
Now, remove or delete that file using following command:
###Remove the file
sudo rm /var/lib/mysql/tc.log
###Rename that file
sudo mv /var/lib/mysql/tc.log /var/lib/mysql/tc.log.old
Finally, restart the MariaDB service:
bonben@ub20:# systemctl start mariadb.service
bonben@ub20:# systemctl status mariadb.service
● mariadb.service - MariaDB 10.3.34 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-11-24 08:37:17 UTC; 5s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 3322 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 3323 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 3325 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 3403 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 3405 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Main PID: 3372 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 32 (limit: 9530)
Memory: 138.0M
CGroup: /system.slice/mariadb.service
└─3372 /usr/sbin/mysqld
Nov 24 08:37:17 store mysqld[3372]: 2022-11-24 8:37:17 0 [Note] /usr/sbin/mysqld (mysqld 10.3.34-MariaDB-0ubuntu0.20.04.1) starting as process 3372 ...
Nov 24 08:37:17 store systemd[1]: Started MariaDB 10.3.34 database server.
Nov 24 08:37:17 store /etc/mysql/debian-start[3407]: Upgrading MySQL tables if necessary.
Nov 24 08:37:17 store /etc/mysql/debian-start[3410]: Looking for 'mysql' as: /usr/bin/mysql
Nov 24 08:37:17 store /etc/mysql/debian-start[3410]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Nov 24 08:37:17 store /etc/mysql/debian-start[3410]: This installation of MariaDB is already upgraded to 10.3.34-MariaDB.
Nov 24 08:37:17 store /etc/mysql/debian-start[3410]: There is no need to run mysql_upgrade again for 10.3.34-MariaDB.
Nov 24 08:37:17 store /etc/mysql/debian-start[3410]: You can use --force if you still want to run mysql_upgrade
Nov 24 08:37:17 store /etc/mysql/debian-start[3418]: Checking for insecure root accounts.
Nov 24 08:37:17 store /etc/mysql/debian-start[3422]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables
5/5 - (1 vote)