升级mysql后,启动失败


➜  ~ service mysqld start
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

查log看看原因,less /var/log/mysqld.log

2017-07-23T16:41:21.182154Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-23T16:41:21.183848Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.19) starting as process 471 ...
2017-07-23T16:41:21.188173Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-07-23T16:41:21.188196Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-07-23T16:41:21.188203Z 0 [Note] InnoDB: Uses event mutexes
2017-07-23T16:41:21.188211Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2017-07-23T16:41:21.188217Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-07-23T16:41:21.188222Z 0 [Note] InnoDB: Using Linux native AIO
2017-07-23T16:41:21.188524Z 0 [Note] InnoDB: Number of pools: 1
2017-07-23T16:41:21.188647Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-07-23T16:41:21.190170Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-07-23T16:41:21.199477Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-07-23T16:41:21.201998Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2017-07-23T16:41:21.211985Z 0 [ERROR] InnoDB: The Auto-extending innodb_system data file './ibdata1' is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2017-07-23T16:41:21.212003Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-07-23T16:41:21.812421Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-07-23T16:41:21.812458Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-07-23T16:41:21.812467Z 0 [ERROR] Failed to initialize plugins.
2017-07-23T16:41:21.812475Z 0 [ERROR] Aborting

2017-07-23T16:41:21.812483Z 0 [Note] Binlog end
2017-07-23T16:41:21.812913Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

查看上面的log,log中说./ibdata1咋咋咋,找到这个文件

➜  ~ find / -name ibdata1
/var/lib/mysql/ibdata1

列目录:

ll /var/lib/mysql/
total 20496
drwxr-x--x   4 mysql mysql     4096 Jul 24 00:41 ./
drwxr-xr-x. 28 root  root      4096 Jul 24 00:37 ../
-rw-rw----   1 mysql mysql 10485760 Jul 24 00:24 ibdata1
-rw-rw----   1 mysql mysql  5242880 Jul 24 00:24 ib_logfile0
-rw-rw----   1 mysql mysql  5242880 Jul 23 11:55 ib_logfile1
drwx------   2 mysql mysql     4096 Jul 24 00:08 laravel/
drwx------   2 mysql mysql     4096 Jul 23 11:55 mysql/

发现有旧版本的数据库在,嗯,问题可能出在这里。
卸载5.1安装升级5.7卸载旧版本没有清除数据库。
执行 rm -r /var/lib/mysql
解决。

在这中间有怀疑过/etc/my.cnf文件没有,实际查看是有的。上面只是最快解决问题途径,这个问题也折腾了半个小时才解决。