mysql官網(wǎng)下載拿到一個(gè)壓縮文件:mysql-5.7.20-winx64.zip解壓
1:配置環(huán)境變量
選取mysql-5.7.20-winx64/bin的絕對(duì)路徑配置環(huán)境變量聚谁,例如:D:/develop/Mysql/mysql-5.7.20-winx64/bin
2:bin目錄下新建my.ini文本(注意文件拓展名)
添加如下內(nèi)容:
[client]
port=3306
default-character-set=utf8
[mysqld]
# 設(shè)置為自己MYSQL的安裝目錄 蜘澜,下面是我的
basedir=D:/develop/Mysql/mysql-5.7.20-winx64
# 設(shè)置為MYSQL的數(shù)據(jù)目錄
datadir=D:/develop/Mysql/mysql-5.7.20-winx64/data
port=3306
character_set_server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
#開(kāi)啟查詢(xún)緩存
explicit_defaults_for_timestamp=true
skip-grant-tables
3:以管理員身份運(yùn)行shell(win10直接右鍵開(kāi)始菜單)
(1)cdD:/develop/Mysql/mysql-5.7.20-winx64/bin進(jìn)入bin目錄
(2)執(zhí)行:?mysqld --initialize-insecure --user=root(
d是daemon守護(hù)線程的意思 啟動(dòng)mysql必須先啟動(dòng)mysql的守護(hù)線程即:mysqld;
--initialize-insecure意為生成沒(méi)有密碼的root用戶虏辫;
user設(shè)置自己習(xí)慣的,這里我設(shè)置為root)
(3)執(zhí)行mysqld -install收到提示Service successfully installed
(4)執(zhí)行net start mysql啟動(dòng)mysql服務(wù)妓布,net stop mysql停止服務(wù)