用 brew
将 mysql
从5.6.22升级到了5.7, 启动mysql
服务之后发现登陆不进去, 原来的密码失效, 应该是两个版本的 mysql.user
表结构的差别形成的, 为了保留以前的数据, 因此卸载了5.7.x
. 卸载以让命令后从新指向5.6.22
, 用mysql.server
命令启动mysql
, 这个时候报错了,启动不了:html
. ERROR! The server quit without updating PID file (/usr/local/var/mysql/xxx.local.pid). 此处的
xxx
是我电脑的名字,下同mysql
这个时候先不要去搜索引擎搜索以上的错误提示,否则会找到不少不一样的无效的解决方案,要定位问题仍是先查看日志,避免作无用功. 我刚开始就是这么作的,浪费了很多时间.sql
查看日志/usr/local/var/mysql/xxx.local.err
, 发现如下问题:服务器
2016-08-03 18:18:59 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-08-03 18:18:59 81707 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive 2016-08-03 18:18:59 81707 [Note] Plugin 'FEDERATED' is disabled. 2016-08-03 18:18:59 81707 [Note] InnoDB: Using atomics to ref count buffer pool pages 2016-08-03 18:18:59 81707 [Note] InnoDB: The InnoDB memory heap is disabled 2016-08-03 18:18:59 81707 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2016-08-03 18:18:59 81707 [Note] InnoDB: Memory barrier is not used 2016-08-03 18:18:59 81707 [Note] InnoDB: Compressed tables use zlib 1.2.3 2016-08-03 18:18:59 81707 [Note] InnoDB: Using CPU crc32 instructions 2016-08-03 18:18:59 81707 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2016-08-03 18:18:59 81707 [Note] InnoDB: Completed initialization of buffer pool 2016-08-03 18:18:59 81707 [Note] InnoDB: Highest supported file format is Barracuda. InnoDB: No valid checkpoint found. InnoDB: If this error appears when you are creating an InnoDB database, InnoDB: the problem may be that during an earlier attempt you managed InnoDB: to create the InnoDB data files, but log file creation failed. InnoDB: If that is the case, please refer to InnoDB: http://dev.mysql.com/doc/refman/5.6/en/error-creating-innodb.html 2016-08-03 18:18:59 81707 [ERROR] Plugin 'InnoDB' init function returned error. 2016-08-03 18:18:59 81707 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2016-08-03 18:18:59 81707 [ERROR] Unknown/unsupported storage engine: InnoDB 2016-08-03 18:18:59 81707 [ERROR] Aborting
重点在:app
InnoDB: to create the InnoDB data files, but log file creation failed.ui
经过这个关键点 google 了一下, 找到解决方法: 删除ib_logfile0
和ib_logfile1
这两个文件,不过最好是重命名这两个文件,就算此方案无效, 还有补救的机会. 接着再启动mysql
服务器, ok 了.this