.1、下載社區版本的服務端
2、將壓縮文件解壓到對應的目錄
3、配置環境變量
4、新建my.ini文件
解壓包里是沒有my-dafault.ini或自帶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. [mysql] #max_sp_recursion_depth=100 [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:\MySQL\mysql-5.6.24-win32.1432006610\mysql-5.6.24-win32 # datadir = D:\MySQL\mysql-5.6.24-win32.1432006610\mysql-5.6.24-win32\data # port = ..... # 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 character-set-server=utf8 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES max_sp_recursion_depth = 100
5、mysql初始化
以管理員權限打開cmd命令窗口,切換到”F:\mysql-5.7.21-winx64\bin”路徑下,輸入指令:
mysqld --initialize --user=mysql --console
該命令會在mysql-5.7.21-winx64目錄下創建data文件夾及初始數據庫,生成root用戶和臨時密碼,紅色標注部分多留意。
6、安裝mysql服務
繼續在窗口輸入指令:
mysqld install MySQL --defaults-file="F:\mysql-5.7.21-winx64\my.ini"
路徑是你my.ini文件的絕對路徑,此時如果遇到錯誤沒能安裝成功,請用管理員身份運行cmd.exe程序再試,正確安裝如下圖:
7、啟動mysql服務
在命令行窗口繼續輸入:
net start mysql
啟動成功,會出現下面的截圖。如果服務一直處於啟動中,說明上一步的操作有誤,核實my.ini文件路徑是否正確
如需修改密碼和配置遠程連接,請參考我的安裝mysql博客,博客鏈接https://www.cnblogs.com/mituxiaogaoyang/p/8655952.html