MySQL安裝教程
- 2019 年 10 月 6 日
- 筆記
完美的MySQL安裝教程,再裝不好,我給你裝去!!!!

首先,把壓縮包給你們:
鏈接:https://pan.baidu.com/s/1eKcAUi0ICyOG60XyS8PkDw 密碼:xacu
一 把文件解壓到一個目錄下


這是解壓後的目錄

新建一個my.ini文件,複製如下內容:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = C:Usersyuqing.wuDesktopmysql-5.7.20-winx64
datadir = C:Usersyuqing.wuDesktopmysql-5.7.20-winx64data
port = 3306
# server_id = …..
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
把藍色的兩行更改成自己的解壓路徑保存
將my.ini文件copy進解壓目錄

右鍵此電腦屬性

找到高級系統設置配置環境變數


新建—》變數值是解壓文件的路徑

Path 單擊path 編輯


新建

之後 用管理員身份打開cmd 進入文件路徑

打開命令行窗口,在裡面輸入:mysqld –install

這個命令是安裝服務, 執行完後,提示英文的成功, 這時候你可以在你的 windows 服務中看到 MySQL 的服務,移除服務命令為:mysqld remove
接著輸入:mysqld –initialize –console
執行這一步,是因為在MySQL5.7中沒有data文件夾,需要用這幾個命令產生data文件夾,並且初始化隨機登陸密碼
執行完會出現一大片英文,看不懂沒關係,在最後面看到有一個root@localhost: 後面有一連串的字母數字元號, 這是MySQL 為你自動生成的隨機密碼. 要記下來, root就是登陸的用戶名,一會我們登陸 MySQL 資料庫的時候要用

4.啟動mysql服務
在安裝後只有啟動了mysql服務才能用,方式有2個
命令行輸入:net start mysql

5.修改默認密碼
之前系統隨機生成的密碼只能用來登陸,然後修改密碼,用不了mysql,只有修改了才能用
啟動了mysql服務後
命令行輸入:mysql -uroot –p

然後會提示要輸入密碼,就是之前生成的密碼
登陸成功就是上圖了,直接輸入:SET PASSWORD =PASSWORD('你的新密碼');

至此mysql已經全部安裝配置完成了,可以直接用了,如圖,可以查看原有的那些資料庫
至此,祝使用愉快!