Mysql

mysql.user 表突然損壞

  • January 14, 2022

我沒有進行升級或其他任何事情,但突然重啟後 MySQL (MariaDB) 停止工作。這是日誌:

2018-02-11 14:10:02 140193631740480 [Note] Using unique option prefix 'innodb_buffer_pool_instance' is error-prone and can break in the future. Please use the full name 'innodb-buffer-pool-instances' instead.
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: The InnoDB memory heap is disabled
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: Using Linux native AIO
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: Using SSE crc32 instructions
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: Initializing buffer pool, size = 2.0G
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: Completed initialization of buffer pool
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: Highest supported file format is Barracuda.
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: The log sequence number 1445306045 in ibdata file do not match the log sequence number 1445306065 in the ib_logfiles!
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: Restoring possible half-written data pages from the doublewrite buffer...
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: 128 rollback segment(s) are active.
2018-02-11 14:10:03 140193631740480 [Note] InnoDB: Waiting for purge to start
2018-02-11 14:10:03 140193631740480 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.36-82.1 started; log sequence number 1445306065
2018-02-11 14:10:03 140190647551744 [Note] InnoDB: Dumping buffer pool(s) not yet started
2018-02-11 14:10:03 140193631740480 [Note] Plugin 'FEEDBACK' is disabled.
2018-02-11 14:10:03 140193631740480 [Note] Recovering after a crash using tc.log
2018-02-11 14:10:03 140193631740480 [Note] Starting crash recovery...
2018-02-11 14:10:03 140193631740480 [Note] Crash recovery finished.
2018-02-11 14:10:03 140193631740480 [Note] Server socket created on IP: '127.0.0.1'.
2018-02-11 14:10:03 140193631740480 [ERROR] Fatal error: mysql.user table is damaged or in unsupported 3.20 format.

我試著環顧四周,但不太明白如何解決它。

試試mysqlcheck --all-databases。那大概會這麼說mysqluser需要修理。然後做

mysqlcheck --all-databases --repair

參考:https ://dev.mysql.com/doc/refman/5.7/en/mysqlcheck.html

我有一個類似的問題。在我的情況下,從舊伺服器導入使用者表並重新啟動 mysql 後,我無法再次啟動它。

我通過以下方式修復了我的使用者表:

  1. 編輯my.cnf(可能在 中/etc/mysql/my.cnf)並附加:
[mysqld]
skip-grant-tables
  1. #service mysql start
  2. #mysql_upgrade
  3. #service mysql restart

不要忘記my.cnf再次編輯並刪除skip-grant-tables

引用自:https://dba.stackexchange.com/questions/197593