背景
5.7版本的mysql離線版安裝有很多坑父叙,在此一一記載。
下載
下載頁面
下載64位zip包肴裙,
解壓
解壓文件趾唱。
初始化配置
在文件目錄下,找到my-default.ini
文件蜻懦,復制并重命名my.ini
甜癞,然后指定data目錄。
# 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.
[client]
port=3306
[mysql]
default-character-set=utf8
[mysqld]
port=3306
basedir="D:/DevelopTools/mysql5_7_14"
datadir="D:/DevelopTools/mysql5_7_14/data"
character-set-server=utf8
default-storage-engine=INNODB
安裝mysql服務(wù)
需要在管理員權(quán)限下執(zhí)行cmd宛乃。
在bin目錄下悠咱,
D:\DevelopTools\mysql5_7_14\bin>mysqld --install
Service successfully installed.
啟動mysql
在bin目錄下,執(zhí)行
D:\DevelopTools\mysql5_7_14\bin>net start mysql
報錯
D:\DevelopTools\mysql5_7_14\bin>net start mysql
MySQL 服務(wù)正在啟動 ..
MySQL 服務(wù)無法啟動征炼。
服務(wù)沒有報告任何錯誤析既。
請鍵入 NET HELPMSG 3534 以獲得更多的幫助。
查看mysql日志
在data目錄下谆奥,查看*.err文件眼坏。
2016-08-23T13:20:42.303713Z 0 [Note] Plugin 'FEDERATED' is disabled.
MySQL: Table 'mysql.plugin' doesn't exist
2016-08-23T13:20:42.305713Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2016-08-23T13:20:42.308713Z 0 [Note] Salting uuid generator variables, current_pid: 3656, server_start_time: 1471958439, bytes_sent: 0,
2016-08-23T13:20:42.337715Z 0 [Note] Generated uuid: '644d3f84-6934-11e6-9f6d-507b9d0180aa', server_start_time: 1471962095, bytes_sent: 109367744
2016-08-23T13:20:42.338715Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 644d3f84-6934-11e6-9f6d-507b9d0180aa.
2016-08-23T13:20:42.365717Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-08-23T13:20:42.368717Z 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-08-23T13:20:42.369717Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2016-08-23T13:20:42.372717Z 0 [Note] IPv6 is available.
2016-08-23T13:20:42.373717Z 0 [Note] - '::' resolves to '::';
2016-08-23T13:20:42.374717Z 0 [Note] Server socket created on IP: '::'.
2016-08-23T13:20:42.380718Z 0 [Warning] Failed to open optimizer cost constant tables
2016-08-23T13:20:42.382718Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
解決方案
http://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
清空data目錄內(nèi)容
首先需要情況data目錄下內(nèi)容,否則會報錯
D:\DevelopTools\mysql5_7_14\bin>mysqld --initialize
2016-08-23T13:27:23.129639Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is
deprecated. Please use --explicit_defaults_for_timestamp server option (see doc
umentation for more details).
2016-08-23T13:27:23.132639Z 0 [ERROR] --initialize specified but the data direct
ory has files in it. Aborting.
2016-08-23T13:27:23.132639Z 0 [ERROR] Aborting
執(zhí)行初始化命令
D:\DevelopTools\mysql5_7_14\bin>mysqld --initialize
啟動服務(wù)
D:\DevelopTools\mysql5_7_14\bin>net start mysql
MySQL 服務(wù)正在啟動 .
MySQL 服務(wù)已經(jīng)啟動成功雄右。
卸載myql服務(wù)
在mysql的bin目錄下:
mysqld --remove
mysql登錄
跳過密碼
首次登錄時空骚,設(shè)置跳過密碼纺讲,可以進入數(shù)據(jù)庫修改密碼信息。
在my.ini
中
# 跳過密碼驗證
skip-grant-tables
修改密碼
mysql> use mysql
Database changed
mysql> update user set authentication_string=password("root") where user="root";
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
重啟服務(wù)后登錄囤屹。
D:\DevelopTools\mysql5_7_14\bin>net stop mysql
MySQL 服務(wù)正在停止.
MySQL 服務(wù)已成功停止熬甚。
D:\DevelopTools\mysql5_7_14\bin>net start mysql
MySQL 服務(wù)正在啟動 .
MySQL 服務(wù)已經(jīng)啟動成功。