MySQL5.7.24壓縮包安裝教程
MySQL安裝包下載:
https://dev.mysql.com/downloads/mysql/
根據需要下載對應版本MySQL
接下來,點選Download,選擇No thanks, just start my download就會直接下載安裝包。
二:配置環境變數
新建MYSQL_HOME變數,變數名為你的解壓路徑名
編輯path變數,在末尾加上 ;%MYSQL_HOME%\bin;
三:解壓安裝包到指定路徑-------my.ini檔案
1. 下載完成後解壓到你想要放的目錄(5.7.20左右的版本(至少5.7.20是),沒my-default.ini這個檔案了)
2. 在bin的同級目錄,新建my-default.ini檔案。我的ini檔案是這樣的:
[mysqld]
port = 3306
basedir=D:\tools\mysql-5.7.24-winx64 //mysql安裝目錄
datadir=D:\tools\mysql-5.7.24-winx64/data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql]
default-character-set=utf8
3. 在bin目錄下面,新建(或者複製my-default.ini)my.ini檔案,不然初始化mysqld --initialize-insecure, data檔案會報找不到資料夾(不能自動生成data資料夾)
我的my.ini:
# 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.
[mysqld]
# 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 = D:\tools\mysql-5.7.24-winx64 //mysql安裝目錄
datadir = D:\tools\mysql-5.7.24-winx64\data
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 = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
四:安裝MySQL服務以及初始化
以管理員身份執行cmd,
以下所有命令都需要進入到mysql安裝目錄的bin目錄下進行!!!
執行安裝mysql服務的命令:mysqld --install
mysqld --install
我們可以看到服務已經成功安裝。
假設這裡出現安裝不成功,那麼就有可能是你之前安裝了但是解除安裝不完全導致的,所以一定要解除安裝完整。
完全解除安裝mysql教程:https://blog.csdn.net/hcrw01/article/details/84261749
初始化MySQL:
mysqld --initialize
初始化完成後會出現data資料夾
如果有data檔案夾了,先刪除掉,再執行mysqld --initialize.
然後啟動MySQL:
net start mysql
MySQL登入:mysql -u root -p
注意:初始密碼可以在生成的data資料夾下字尾名為.err的檔案
然後設定自己的登入密碼:
alter user user() identified by "你的新密碼";
mysql>FLUSH PRIVILEGES; //重新整理許可權