離線版Mysql安裝(5.7)

背景

5.7版本的mysql離線版安裝有很多坑,在此一一記載。

下載

下載頁面

下載64位zip包,

解壓

解壓文件。

初始化配置

在文件目錄下,找到my-default.ini文件,復(fù)制并重命名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è)置跳過密碼,可以進(jìn)入數(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)啟動成功。
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容