安裝過程:
1. 官網下載5.15.7, http://dev.mysql.com/downloads/, 選擇開源社區版:MySQL Community Server (GPL)
2. 我解壓后放在 E:\mysql\5.7.15\ 下面
3. 將E:\mysql\5.7.15\bin加入系統path
4. 安裝mysql服務: mysqld --install
5. 編輯E:\mysql\5.7.15\my.ini文件
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] basedir = E:/mysql/5.7.15 datadir = E:/mysql/data port = 3306 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
6. 用管理員身份打開cmd命令窗口
7. 初始化mysql: mysqld --initialize
8. 啟動mysql服務: net start mysql
====================================================================
遇到的問題:
問題1:
E:\mysql\5.7.15>net start mysql MySQL 服務正在啟動 . MySQL 服務無法啟動。 服務沒有報告任何錯誤。 請鍵入 NET HELPMSG 3534 以獲得更多的幫助。 E:\mysql\5.7.15>net helpmsg 3534 服務沒有報告任何錯誤。
問題2:
這個錯誤沒有仍和日志記錄,原因是my.ini中datadir所設定的目錄不存在,路徑分隔符需要采用linux格式“/”, 而不是“\"
如果mysql找不到這個data目錄, 那么初始化會出錯:
E:\mysql\5.7.15\bin>mysqld --initialize mysqld: Can't create directory 'E:\myusql\data\' (Errcode: 2 - No such file or directory) 2016-09-16T07:52:37.476808Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-09-16T07:52:37.476808Z 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-09-16T07:52:37.476808Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set. 2016-09-16T07:52:37.492808Z 0 [ERROR] Aborting
問題3: data目錄非空,也會初始化也會出錯:
E:\mysql\5.7.15\bin>mysqld --initialize 2016-09-16T07:53:33.306817Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-09-16T07:53:33.306817Z 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-09-16T07:53:33.306817Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set. 2016-09-16T07:53:33.310106Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2016-09-16T07:53:33.318664Z 0 [ERROR] Aborting