Lỗi service mysql không thể start:[ERROR] mysqld: Table ‘./mysql/global_priv’ is marked as crashed
Trạng thái lỗi:
[root@ctr979447 mysql]# systemctl status mysqld
.........
Aug 29 13:48:41 ctr979447.nhanhoa mysqld[6701]: 2025-08-29 13:48:41 0 [ERROR] mysqld: Table './mysql/global_priv' is marked as crashed and last (automatic?) repair failed
Aug 29 13:48:41 ctr979447.nhanhoa mysqld[6701]: 2025-08-29 13:48:41 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/global_priv' is marked as crashed and last (automatic?) repair failed
Aug 29 13:48:41 ctr979447.nhanhoa mysqld[6701]: 2025-08-29 13:48:41 0 [ERROR] Aborting
Aug 29 13:48:42 ctr979447.nhanhoa systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Aug 29 13:48:42 ctr979447.nhanhoa systemd[1]: Failed to start MariaDB database server.
Aug 29 13:48:42 ctr979447.nhanhoa systemd[1]: Unit mariadb.service entered failed state.
Aug 29 13:48:42 ctr979447.nhanhoa systemd[1]: mariadb.service failed.
Nguyên nhân:
Lỗi do bảng mysql.global_priv
bị crash (hỏng). Đây là bảng chứa thông tin quyền truy cập (user, password, grant), nên nếu nó lỗi thì mysql không thể khởi động.
Cách xử lý:
SSH vào VPS thao tác các bước sau:
vi /etc/my.cnf thêm vào cuối cùng dòng:
skip-grant-tables
Khởi động lại mysql
systemctl restart mysqld
Đăng nhập vào mysql:
[root@ctr979447 mysql]# mysql
MariaDB [(none)]> USE mysql;
MariaDB [mysql]> REPAIR TABLE global_priv;
Xóa cấu hình skip-grant-tables
Mở lại file /etc/my.cnf xóa bỏ dòng skip-grant-tables
Khởi động lại mysql
systemctl restart mysqld
Sau khi restart dịch vụ hoạt động lại bình thường.