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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM