linux下apt安裝mysql導致mysql.user table is damaged
阿新 • • 發佈:2018-12-28
筆者在ubuntu下用 apt install mysql-server類似的命令安裝mysql,
安裝了最新版的mysql5.7,覆蓋了作業系統內建的資料庫mysql系統庫。
最初啟動mysql出錯資訊如下
service mysql start Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
檢視日誌資訊如下:
tail-100f /var/log/mysql/error.log
2018-12-27T23:10:32.624983Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000) 2018-12-27T23:10:32.625097Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000) 2018-12-27T23:10:32.803581Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore details). 2018-12-27T23:10:32.805744Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.24-0ubuntu0.16.04.1) starting as process 20295 ... 2018-12-27T23:10:32.811597Z 0 [Note] InnoDB: PUNCH HOLE support available 2018-12-27T23:10:32.811655Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2018-12-27T23:10:32.811662Z 0 [Note] InnoDB: Uses event mutexes 2018-12-27T23:10:32.811667Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2018-12-27T23:10:32.811671Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8 2018-12-27T23:10:32.811676Z 0 [Note] InnoDB: Using Linux native AIO 2018-12-27T23:10:32.812040Z 0 [Note] InnoDB: Number of pools: 1 2018-12-27T23:10:32.812208Z 0 [Note] InnoDB: Using CPU crc32 instructions 2018-12-27T23:10:32.814479Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2018-12-27T23:10:32.826619Z 0 [Note] InnoDB: Completed initialization of buffer pool 2018-12-27T23:10:32.829478Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2018-12-27T23:10:32.842451Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2018-12-27T23:10:32.851779Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2018-12-27T23:10:32.851863Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2018-12-27T23:10:32.887533Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2018-12-27T23:10:32.888429Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2018-12-27T23:10:32.888458Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2018-12-27T23:10:32.888905Z 0 [Note] InnoDB: Waiting for purge to start 2018-12-27T23:10:32.939190Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 2671864 2018-12-27T23:10:32.939462Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2018-12-27T23:10:32.939724Z 0 [Note] Plugin 'FEDERATED' is disabled. 2018-12-27T23:10:32.941332Z 0 [Note] InnoDB: Buffer pool(s) load completed at 181227 23:10:32 2018-12-27T23:10:32.945460Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key 2018-12-27T23:10:32.945498Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2018-12-27T23:10:32.945538Z 0 [Note] IPv6 is available. 2018-12-27T23:10:32.945566Z 0 [Note] - '::' resolves to '::'; 2018-12-27T23:10:32.945589Z 0 [Note] Server socket created on IP: '::'. 2018-12-27T23:10:32.946334Z 0 [ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade. 2018-12-27T23:10:32.946376Z 0 [ERROR] Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files. 2018-12-27T23:10:32.946415Z 0 [ERROR] Aborting
解決方法如下:
https://serverfault.com/questions/789328/fatal-error-mysql-user-table-is-damaged-please-run-mysql-upgrade
/etc/init.d/mysql start --skip-grant-tables && mysql_upgrade
service mysql restart
其他參考:
https://fatdba.com/2017/11/15/mysql-startup-error-error-fatal-error-mysql-user-table-is-damaged/
https://serverfault.com/questions/527422/mysql-upgrade-is-failing-with-no-real-reason-given