笔者在ubuntu下用 apt install mysql-server类似的命令安装mysql,
安装了最新版的mysql5.7,覆盖了操作系统内置的数据库mysql系统库。
最初启动mysql出错信息如下
service mysql start
Jobfor 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 for moredetails).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 available2018-12-27T23:10:32.811655Z 0[Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2018-12-27T23:10:32.811662Z 0[Note] InnoDB: Uses event mutexes2018-12-27T23:10:32.811667Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used formemory barrier2018-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 AIO2018-12-27T23:10:32.812040Z 0 [Note] InnoDB: Number of pools: 1
2018-12-27T23:10:32.812208Z 0[Note] InnoDB: Using CPU crc32 instructions2018-12-27T23:10:32.814479Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size =128M2018-12-27T23:10:32.826619Z 0[Note] InnoDB: Completed initialization of buffer pool2018-12-27T23:10:32.829478Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the manpage of setpriority().2018-12-27T23:10:32.842451Z 0 [Note] InnoDB: Highest supported fileformat is Barracuda.2018-12-27T23:10:32.851779Z 0 [Note] InnoDB: Creating shared tablespace fortemporary tables2018-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 12MB.2018-12-27T23:10:32.888429Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96redo 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 forpurge to start2018-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_pool2018-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 key2018-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
vim /etc/mysql/mysqld.conf/mysql.cnf
[mysqld]添加以下内容
skip-grant-tables
/etc/init.d/mysql start --skip-grant-tables && mysql_upgrade
service mysql restart
如果以上方法无效,完整删除mysql重新安装
apt remove mysql*
rm -rf /var/lib/mysql
apt install mysql-server mysql-client
dpkg --configure -a
其他参考:
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