1. 下載下傳MySQL zip 版本
http://dev.mysql.com/downloads/mysql/
2. 解壓下載下傳的zip檔案,到自己的準備安裝目錄,e.g: D:\tools\mysql-8.0.22-winx64
3. 添加環境變量到path(目錄為安裝目錄裡面的bin: D:\tools\mysql-8.0.22-winx64\bin)
4. 解壓出來的zip檔案不包含my.ini檔案,是以我們需要建立一個作為其初始化配置。
1 [mysqld]
2
3 #Path to installation directory. All paths are usually resolved relative to this.
4 basedir="D:\\tools\\mysql-8.0.22-winx64"
5
6 #Path to the database root
7 datadir="D:\\tools\\mysql-8.0.22-winx64\\data"
8
9 # The TCP/IP Port the MySQL Server will listen on
10 port=3306
11
12 # ignore the auth
13 skip-grant-tables
5. 啟動管理者模式下的cmd, 将路徑切換到mysql裡面的bin目錄,然後輸入mysqld -install進行安裝

如果安裝過程遇到“無法啟動此程式,因為計算機中丢失VCRUNTIME140_1.dll。嘗試重新安裝該程式一解決問題”
解決方案如下:
去微軟官網下載下傳安裝 Visual C++
下載下傳位址:https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
根據自己電腦位數進行選擇
下載下傳後,進行安裝。安裝成功後,在 C:\Windows\System32 目錄就有了 VCRUNTIME140_1.dll 檔案
6. 再輸入如下指令進行初始化資料檔案:
mysqld --initialize-insecure --user=mysql
将會自動建立data檔案夾:
7. 啟動mysql服務:
net start mysql
8. 使用如下指令進入mysql管理界面(這一步密碼為空)
mysql -u root -p
如果由上述錯誤,找到如下圖所示,點選啟動:
但是啟動完又自動停止,檢視mysql error log,
解決辦法:
my.ini 檔案添加行:
1 shared-memory
進入MySQL成功。
9. 修改密碼:
MySQL8以前:update mysql.user set authentication_string=password('123456') where user='root' and Host='localhost';
mysql8: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY'123456';
10. 停止mysql服務,注釋掉my.ini檔案裡面的“#skip-grant-tables”,重新開機mysql服務,使用密碼進行登入。
mysql -u root -p123456
如果需要删除這種方式安裝的MySQL的話: