Categories
Linux Server

Fix MariaDB can’t start

I used RunCloud to manage my servers and my web application. Once we got an error with MariaDB offline cause one of a database has been crashed.

To see all services in a Linux server:

systemctl list-units --all --type=service --no-pager

To detect the latest error with the database, run this code. It will return the last error.

systemctl status mariadb.service

I found two issues with my server:

 0 [Note] /usr/sbin/mysqld (mysqld 10.4.21-MariaDB-1:10.4.21+maria~bionic-log) starting as process 18575 ...
 0 [ERROR] mysqld: File '/var/log/mysql/mariadb-bin.index' not found (Errcode: 2 "No such file or directory")
 0 [ERROR] Aborting
Sep 25 22:53:07 ubuntu mysqld[19456]: 2021-09-25 22:53:07 66 [ERROR] mysqld: Table './db_name/wp_postmeta' is marked as crashed and should be repaired
Sep 25 22:53:07 ubuntu mysqld[19456]: 2021-09-25 22:53:07 66 [Warning] Checking table:   './db_name/wp_postmeta'
Sep 25 22:53:08 ubuntu mysqld[19456]: 2021-09-25 22:53:08 72 [ERROR] mysqld: Table './db_name/wp_posts' is marked as crashed and should be repaired
Sep 25 22:53:08 ubuntu mysqld[19456]: 2021-09-25 22:53:08 72 [Warning] Checking table:   './db_name/wp_posts'

To fix that, I ran a below command:

mysqlcheck --repair --all-databases

Then start a MariaDB again. It works!

Leave a Reply

Your email address will not be published. Required fields are marked *