Mysql-5.7.10启动失败 。
Mysql-5.7.10在免安装后启动服务失败。
查看日志得到如下:
2016-02-19T03:41:05.557095Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-02-19T03:41:05.557095Z 0 [Warning] \'NO_ZERO_DATE\', \'NO_ZERO_IN_DATE\' and \'ERROR_FOR_DIVISION_BY_ZERO\' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2016-02-19T03:41:05.557095Z 0 [Warning] \'NO_AUTO_CREATE_USER\' sql mode was not set. 2016-02-19T03:41:05.557095Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path. 2016-02-19T03:41:05.557095Z 0 [Note] C:\MySql\mysql-5.7.10-winx64\bin\mysqld (mysqld 5.7.10) starting as process 7164 ... 2016-02-19T03:41:05.573096Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions 2016-02-19T03:41:05.574096Z 0 [Note] InnoDB: Uses event mutexes 2016-02-19T03:41:05.574096Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier 2016-02-19T03:41:05.575096Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2016-02-19T03:41:05.576096Z 0 [Note] InnoDB: Number of pools: 1 2016-02-19T03:41:05.576096Z 0 [Note] InnoDB: Not using CPU crc32 instructions 2016-02-19T03:41:05.620099Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2016-02-19T03:41:05.632099Z 0 [Note] InnoDB: Completed initialization of buffer pool 2016-02-19T03:41:05.712104Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2016-02-19T03:41:05.814110Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2016-02-19T03:41:05.815110Z 0 [Note] InnoDB: Setting file \'.\ibtmp1\' size to 12 MB. Physically writing the file full; Please wait ... 2016-02-19T03:41:05.857112Z 0 [Note] InnoDB: File \'.\ibtmp1\' size is now 12 MB. 2016-02-19T03:41:05.859112Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2016-02-19T03:41:05.860112Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2016-02-19T03:41:05.862113Z 0 [Note] InnoDB: 5.7.10 started; log sequence number 1210198 2016-02-19T03:41:05.863113Z 0 [Note] InnoDB: Loading buffer pool(s) from C:\MySql\mysql-5.7.10-winx64\data\ib_buffer_pool 2016-02-19T03:41:05.864113Z 0 [Note] Plugin \'FEDERATED\' is disabled. 2016-02-19T03:41:05.864113Z 0 [Note] InnoDB: not started mysqld: Table \'mysql.plugin\' doesn\'t exist 2016-02-19T03:41:05.865113Z 0 [ERROR] Can\'t open the mysql.plugin table. Please run mysql_upgrade to create it. 2016-02-19T03:41:05.866113Z 0 [Note] InnoDB: Buffer pool(s) load completed at 160219 11:41:05 2016-02-19T03:41:05.866113Z 0 [Warning] Gtid table is not ready to be used. Table \'mysql.gtid_executed\' cannot be opened. 2016-02-19T03:41:05.867113Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key 2016-02-19T03:41:05.868113Z 0 [Note] Server hostname (bind-address): \'*\'; port: 3306 2016-02-19T03:41:05.870113Z 0 [Note] IPv6 is available. 2016-02-19T03:41:05.871113Z 0 [Note] - \'::\' resolves to \'::\'; 2016-02-19T03:41:05.871113Z 0 [Note] Server socket created on IP: \'::\'. 2016-02-19T03:41:05.873113Z 0 [Warning] Failed to open optimizer cost constant tables 2016-02-19T03:41:05.874113Z 0 [ERROR] Fatal error: Can\'t open and lock privilege tables: Table \'mysql.user\' doesn\'t exist 2016-02-19T03:41:05.875113Z 0 [ERROR] Aborting 2016-02-19T03:41:05.875113Z 0 [Note] Binlog end 2016-02-19T03:41:05.875113Z 0 [Note] Shutting down plugin \'ngram\' 2016-02-19T03:41:05.876113Z 0 [Note] Shutting down plugin \'partition\' 2016-02-19T03:41:05.876113Z 0 [Note] Shutting down plugin \'BLACKHOLE\' 2016-02-19T03:41:05.876113Z 0 [Note] Shutting down plugin \'ARCHIVE\' 2016-02-19T03:41:05.877113Z 0 [Note] Shutting down plugin \'PERFORMANCE_SCHEMA\' 2016-02-19T03:41:05.877113Z 0 [Note] Shutting down plugin \'MRG_MYISAM\' 2016-02-19T03:41:05.877113Z 0 [Note] Shutting down plugin \'MyISAM\' 2016-02-19T03:41:05.878113Z 0 [Note] Shutting down plugin \'INNODB_SYS_VIRTUAL\' 2016-02-19T03:41:05.878113Z 0 [Note] Shutting down plugin \'INNODB_SYS_DATAFILES\' 2016-02-19T03:41:05.879114Z 0 [Note] Shutting down plugin \'INNODB_SYS_TABLESPACES\' 2016-02-19T03:41:05.879114Z 0 [Note] Shutting down plugin \'INNODB_SYS_FOREIGN_COLS\' 2016-02-19T03:41:05.879114Z 0 [Note] Shutting down plugin \'INNODB_SYS_FOREIGN\' 2016-02-19T03:41:05.880114Z 0 [Note] Shutting down plugin \'INNODB_SYS_FIELDS\' 2016-02-19T03:41:05.880114Z 0 [Note] Shutting down plugin \'INNODB_SYS_COLUMNS\' 2016-02-19T03:41:05.881114Z 0 [Note] Shutting down plugin \'INNODB_SYS_INDEXES\' 2016-02-19T03:41:05.881114Z 0 [Note] Shutting down plugin \'INNODB_SYS_TABLESTATS\' 2016-02-19T03:41:05.881114Z 0 [Note] Shutting down plugin \'INNODB_SYS_TABLES\' 2016-02-19T03:41:05.882114Z 0 [Note] Shutting down plugin \'INNODB_FT_INDEX_TABLE\' 2016-02-19T03:41:05.882114Z 0 [Note] Shutting down plugin \'INNODB_FT_INDEX_CACHE\' 2016-02-19T03:41:05.883114Z 0 [Note] Shutting down plugin \'INNODB_FT_CONFIG\' 2016-02-19T03:41:05.883114Z 0 [Note] Shutting down plugin \'INNODB_FT_BEING_DELETED\' 2016-02-19T03:41:05.883114Z 0 [Note] Shutting down plugin \'INNODB_FT_DELETED\' 2016-02-19T03:41:05.884114Z 0 [Note] Shutting down plugin \'INNODB_FT_DEFAULT_STOPWORD\' 2016-02-19T03:41:05.884114Z 0 [Note] Shutting down plugin \'INNODB_METRICS\' 2016-02-19T03:41:05.885114Z 0 [Note] Shutting down plugin \'INNODB_TEMP_TABLE_INFO\' 2016-02-19T03:41:05.885114Z 0 [Note] Shutting down plugin \'INNODB_BUFFER_POOL_STATS\' 2016-02-19T03:41:05.886114Z 0 [Note] Shutting down plugin \'INNODB_BUFFER_PAGE_LRU\' 2016-02-19T03:41:05.886114Z 0 [Note] Shutting down plugin \'INNODB_BUFFER_PAGE\' 2016-02-19T03:41:05.886114Z 0 [Note] Shutting down plugin \'INNODB_CMP_PER_INDEX_RESET\' 2016-02-19T03:41:05.887114Z 0 [Note] Shutting down plugin \'INNODB_CMP_PER_INDEX\' 2016-02-19T03:41:05.887114Z 0 [Note] Shutting down plugin \'INNODB_CMPMEM_RESET\' 2016-02-19T03:41:05.888114Z 0 [Note] Shutting down plugin \'INNODB_CMPMEM\' 2016-02-19T03:41:05.888114Z 0 [Note] Shutting down plugin \'INNODB_CMP_RESET\' 2016-02-19T03:41:05.888114Z 0 [Note] Shutting down plugin \'INNODB_CMP\' 2016-02-19T03:41:05.889114Z 0 [Note] Shutting down plugin \'INNODB_LOCK_WAITS\' 2016-02-19T03:41:05.889114Z 0 [Note] Shutting down plugin \'INNODB_LOCKS\' 2016-02-19T03:41:05.889114Z 0 [Note] Shutting down plugin \'INNODB_TRX\' 2016-02-19T03:41:05.890114Z 0 [Note] Shutting down plugin \'InnoDB\' 2016-02-19T03:41:05.890114Z 0 [Note] InnoDB: FTS optimize thread exiting. 2016-02-19T03:41:05.890114Z 0 [Note] InnoDB: Starting shutdown... 2016-02-19T03:41:05.991120Z 0 [Note] InnoDB: Dumping buffer pool(s) to C:\MySql\mysql-5.7.10-winx64\data\ib_buffer_pool 2016-02-19T03:41:05.993120Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 160219 11:41:05 2016-02-19T03:41:07.311195Z 0 [Note] InnoDB: Shutdown completed; log sequence number 1210217 2016-02-19T03:41:07.312196Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 2016-02-19T03:41:07.314196Z 0 [Note] Shutting down plugin \'MEMORY\' 2016-02-19T03:41:07.314196Z 0 [Note] Shutting down plugin \'CSV\' 2016-02-19T03:41:07.315196Z 0 [Note] Shutting down plugin \'sha256_password\' 2016-02-19T03:41:07.316196Z 0 [Note] Shutting down plugin \'mysql_native_password\' 2016-02-19T03:41:07.316196Z 0 [Note] Shutting down plugin \'binlog\' 2016-02-19T03:41:07.317196Z 0 [Note] C:\MySql\mysql-5.7.10-winx64\bin\mysqld: Shutdown complete
网上看了多信息仍未解决,最终去官网上找到了原因,原来data目录是我手工创建的,还必须执行如下命令进行初始化。
http://dev.mysql.com/doc/refman/5.7/en/windows-extract-archive.html
http://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
To initialize the data directory, invoke mysqld with the --initialize
or --initialize-insecure
option, depending on whether you want the server to generate a random initial password for the \'root\'@\'localhost\'
account.
On Windows, use one of these commands:
C:\>bin\mysqld --initialize
C:\>bin\mysqld --initialize-insecure 这个命令会创建空密码的 root@localhost 账号,否则会创建带密码的 root@localhost 账号,密码直接写在 log-error 日志文件中
执行完这命令,
再执行 mysqld install MySQL –defaults-file=”D:\Program Files\MySQL\mysql-5.6.13-win32\my.ini”
果然mysql服务就正常启动了。
记录下安装步骤:
添加环境变量
变量名:MYSQL_HOME
变量值:D:\Program Files\mysql-5.6.14-winx64
即为mysql的自定义解压目录。
再在Path中添加 %MYSQL_HOME%\bin
添加为服务:
从控制台进入到MySQL解压目录下的 bin 目录下:
bin\mysqld --initialize-insecure
输入服务安装命令:
mysqld install MySQL –defaults-file=”D:\Program Files\MySQL\mysql-5.6.13-win32\my.ini”
#解压目录下修改的my.ini文件
安装成功后会提示服务安装成功。
#注:my.ini文件放在MySQL解压后的根目录下
#移除服务命令为:mysqld remove
附上myini文件:
[client] port=3306 default-character-set=utf8 [mysqld] port=3306 character_set_server=utf8 #解压目录 basedir=C:\MySql\mysql-5.7.10-winx64 #解压目录下data目录 datadir=C:\MySql\mysql-5.7.10-winx64\data #没有这行在5.7中要这行,否则初始化时会有警告: [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see doc umentation for more details). explicit_defaults_for_timestamp=true [WinMySQLAdmin] C:\MySql\mysql-5.7.10-winx64\bin\mysqld.exe