Windows 中 安裝zip歸檔版 MySQL
阿新 • • 發佈:2021-01-23
技術標籤:MySQL/NoSQL
環境:
作業系統: Windows7 sp1 旗艦版 64位
MySQL包:mysql-5.5.62-winx64.zip
1. 解壓 MySQL zip安裝包 到 需要的位置,並將解壓出來的資料夾重新命名為 mysql
2.建立 MySQL 配置檔案,其基本內容為 MySQL 的安裝目錄 和 MySQL 的 data 資料
庫存放目錄,例如:
[mysqld] # set basedir to your installation path basedir=E:/mysql # set datadir to the location of your data directory datadir=E:/mydata/data
這是基本的內容,更多配置項請參考:https://dev.mysql.com/doc/refman/5.6/en/server-option-variable-reference.html
3.首次啟動 MySQL
首次啟動建議 通過 命令列 啟動,這樣便於檢視訊息解決問題(注意路徑替換為你的)。
C:\> "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld" --console
如果伺服器 支援 InnoDB ,在啟動時則會看到類似如下資訊:
InnoDB: The first specified datafile c:\ibdata\ibdata1 did not exist: InnoDB: a new database to be created! InnoDB: Setting file c:\ibdata\ibdata1 size to 209715200 InnoDB: Database physically writes the file full: wait... InnoDB: Log file c:\iblogs\ib_logfile0 did not exist: new to be created InnoDB: Setting log file c:\iblogs\ib_logfile0 size to 31457280 InnoDB: Log file c:\iblogs\ib_logfile1 did not exist: new to be created InnoDB: Setting log file c:\iblogs\ib_logfile1 size to 31457280 InnoDB: Log file c:\iblogs\ib_logfile2 did not exist: new to be created InnoDB: Setting log file c:\iblogs\ib_logfile2 size to 31457280 InnoDB: Doublewrite buffer not found: creating new InnoDB: Doublewrite buffer created InnoDB: creating foreign key constraint system tables InnoDB: foreign key constraint system tables created 011024 10:58:25 InnoDB: Started
當,看到如下資訊時,則表明,伺服器啟動成功可以連線:
mysqld: ready for connections
Version: '5.6.51' socket: '' port: 3306
4.從 Windows 命令列中 啟動 MySQL(注意路徑替換為你的)
C:\> "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld"
5.從 Windows 命令列中 停止 MySQL(注意路徑替換為你的)
C:\> "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqladmin" -u root shutdown
6.開機自啟動。將 MySQL 安裝為系統服務(注意路徑替換為你的),安裝前先使用上述命令停止MySQL。
C:\> "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld" --install
7.還可以 新增 --defaults-file 來指定 MySQL的配置檔案 my.cnf,例如:
C:\> "C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld" --install --defaults-file=C:\MySQL\my.cnf
詳情請參考:https://dev.mysql.com/doc/refman/5.6/en/windows-start-service.html
最後再將 MySQL 加入系統環境變數