Windows Server 2008完美安裝MySQL Community Server 5.7.16六步曲

Hoegh發表於2016-10-20
    今天在Windows Server 2008 r2系統下部署了MySQL Community Server 5.7.16,安裝過程中也遇到了一些問題,在這兒記錄一下最終的安裝過程。

0.下載安裝介質

   我們可以登入MySQL官網來下載安裝介質,網址是:http://dev.mysql.com/downloads/。我選擇的是64位壓縮包版本“Windows (x86, 64-bit), ZIP Archive”。


1.解壓縮

將下載到本地的安裝介質解壓縮。然後,將解壓後的資料夾mysql-5.7.16-winx64拷貝到安裝目錄(E盤根目錄)下。

2.設定系統環境變數

右鍵點選 計算機>>屬性>> 高階系統屬性>>環境變數>> 編輯 Path ,在最後新增” ;E:\mysql-5.7.16-winx64\bin“,確定。

3.建立my.ini 檔案和data目錄,配置安裝路徑與資料儲存路徑

E:\mysql-5.7.16-winx64目錄下建立data目錄和my.ini,並在my.ini中配置安裝路徑與資料儲存路徑等資訊。

點選(此處)摺疊或開啟

  1. [mysql]
  2. default-character-set=utf8
  3. [mysqld]
  4. max_connections=200
  5. default-storage-engine=INNODB
  6. basedir =E:\mysql-5.7.16-winx64\bin
  7. datadir =E:\mysql-5.7.16-winx64\data
  8. port = 3306

4.安裝MySQL服務

首先,以管理員身份執行 cmd 並切換到MySQL的bin目錄下;

接下來,執行mysqld --initialize-insecure

    這條命令用來初始化data文件,其中insecure選項指定登入無需口令。

點選(此處)摺疊或開啟

  1. D:\>e:
  2. E:\>cd mysql-5.7.16-winx64
  3. E:\mysql-5.7.16-winx64>cd bin
  4. E:\mysql-5.7.16-winx64\bin>mysqld --initialize-insecure
  5. E:\mysql-5.7.16-winx64\bin>
需要注意的是,如果不指定insecure選項,則會隨機生成登陸密碼, 在E:\mysql-5.7.16-winx64\data資料夾下,有一個 hoegh.err 檔案,其中hoegh是主機名,開啟會看到:
2016-10-20T09:34:56.806257Z 1 [Note] A temporary password is generated for root@localhost: p-mcI:ijR6Xg,
其中 p-mcI:ijR6Xg即為隨機密碼。

然後,輸入 mysqld --install安裝MySQL服務

我們會看到介面出現:Server successfully installed,這就說明MySQL服務安裝成功。 

點選(此處)摺疊或開啟

  1. E:\mysql-5.7.16-winx64\bin>
  2. E:\mysql-5.7.16-winx64\bin>mysqld --install
  3. Service successfully installed.
  4. E:\mysql-5.7.16-winx64\bin>

5.啟動MySQL服務

輸入  net start mysql  回車, 就會看到: MySQL 服務已經啟動成功。嘗試使用root使用者登入資料庫,並通過show databases命令檢視資料庫概要資訊。

點選(此處)摺疊或開啟

  1. E:\mysql-5.7.16-winx64\bin>
  2. E:\mysql-5.7.16-winx64\bin>net start mysql
  3. MySQL 服務正在啟動 .
  4. MySQL 服務已經啟動成功。


  5. E:\mysql-5.7.16-winx64\bin>mysql -u root
  6. Welcome to the MySQL monitor. Commands end with ; or \g.
  7. Your MySQL connection id is 2
  8. Server version: 5.7.16 MySQL Community Server (GPL)

  9. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

  10. Oracle is a registered trademark of Oracle Corporation and/or its
  11. affiliates. Other names may be trademarks of their respective
  12. owners.

  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  14. mysql> show databases;
  15. +--------------------+
  16. | Database |
  17. +--------------------+
  18. | information_schema |
  19. | mysql |
  20. | performance_schema |
  21. | sys |
  22. +--------------------+
  23. 4 rows in set (0.00 sec)

  24. mysql>

6.修改root密碼

    安全起見,我們修改一下root密碼。

點選(此處)摺疊或開啟

  1. mysql>
  2. mysql> alter user 'root'@'localhost' identified by 'root';
  3. Query OK, 0 rows affected (0.00 sec)

  4. mysql>
  5. mysql> exit
  6. Bye

  7. E:\mysql-5.7.16-winx64\bin>mysql -u root -proot
  8. mysql: [Warning] Using a password on the command line interface can be insecure.
  9. Welcome to the MySQL monitor. Commands end with ; or \g.
  10. Your MySQL connection id is 4
  11. Server version: 5.7.16 MySQL Community Server (GPL)

  12. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

  13. Oracle is a registered trademark of Oracle Corporation and/or its
  14. affiliates. Other names may be trademarks of their respective
  15. owners.

  16. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  17. mysql> show databases;
  18. +--------------------+
  19. | Database |
  20. +--------------------+
  21. | information_schema |
  22. | mysql |
  23. | performance_schema |
  24. | sys |
  25. +--------------------+
  26. 4 rows in set (0.00 sec)

  27. mysql>


~~~~~~~ the end~~~~~~~~~
hoegh
2016.10.20

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30162081/viewspace-2126797/,如需轉載,請註明出處,否則將追究法律責任。

相關文章