標籤:monitor window gtid constrain 5.7 statement 過程 val 檔案
Windows下安裝配置免安裝MySQL5.7伺服器
1、下載、解壓安裝包
從MySQL官方網站上下載mysql-5.7.19-winx64.zip
下載完成後,把安裝包解壓到D:\DevSoftware\mysql57\目錄下,會產生一個mysql-5.7.19-winx64目錄。現在MySQL的目錄就是D:\DevSoftware\mysql57\mysql-5.7.19-winx64
2、建立資料目錄
在D:\DevSoftware\mysql57\下建立一個data目錄,作為mysql伺服器的資料目錄。
3、建立設定檔
在D:\DevSoftware\mysql57\mysql-5.7.19-winx64\建立一個my.ini檔案,做為mysql的設定檔。
其內容為:
[mysqld]basedir=D:/DevSoftware/mysql57/mysql-5.7.19-winx64datadir=D:/DevSoftware/mysql57/dataport=3306
現在MySQL安裝目錄中的結構是這樣的:
D:\DevSoftware\mysql57\
|--mysql-5.7.19-winx64\
|--data
|--mysql-5.7.19-winx64\my.ini
這樣MySQL軟體的目錄,資料目錄data,和設定檔,就形成了這樣一個結構。
4、添加mysql的bin目錄到環境變數path中
把D:\DevSoftware\mysql57\mysql-5.7.19-winx64\bin目錄添加到PATH環境變數中去。
5、把mysql伺服器安裝成windows服務
以管理員權限運行CMD,進入到D:\DevSoftware\mysql57\mysql-5.7.19-winx64\bin目錄中,執行:
mysqld --install
就可以把mysql伺服器註冊成windows服務了。
D:\DevSoftware\mysql57\mysql-5.7.19-winx64\bin>mysqld --installService successfully installed.
6、初始化MySQL資料庫
在CMD中,進入到mysql安裝目錄的bin下,執行
mysqld --initialize --console
就可以初始化資料庫了。如果初始化過程中報錯,一般是data目錄下有檔案,進入data目錄,刪除其中的檔案,再次執行初始化語句,就可以成功了。
初始化完成後,初始化資訊中會給出root使用者的隨機密碼,記住這個密碼,接下來登陸mysql伺服器時,需要輸入這個密碼。
D:\DevSoftware\mysql57\mysql-5.7.19-winx64\bin>mysqld --initialize --console2017-08-04T10:06:35.200271Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2017-08-04T10:06:36.851562Z 0 [Warning] InnoDB: New log files created, LSN=457902017-08-04T10:06:37.312575Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2017-08-04T10:06:37.655489Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 9a753507-78fc-11e7-a67d-54e1ad300ba0.2017-08-04T10:06:37.691852Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.2017-08-04T10:06:37.713805Z 1 [Note] A temporary password is generated for [email protected]: lwuW>7sxauEG
7、啟動mysql伺服器
因為mysql伺服器已經被註冊成Windows服務了,所以可以通過啟動Windows服務的方式去啟動mysql伺服器。
在cmd中執行net start mysql。
D:\DevSoftware\mysql57\mysql-5.7.19-winx64\bin>net start mysqlMySQL 服務正在啟動 .MySQL 服務已經啟動成功。
8、登陸mysql伺服器,並修改root密碼
啟動mysql伺服器之後,就可以登陸伺服器了。登陸伺服器的時候需要輸入root密碼,root的密碼就是初始化資料庫後,系統給出的隨機密碼。
登陸到伺服器之後,不能執行其他語句,必須先修改root使用者密碼。具體資訊,見:
D:\DevSoftware\mysql57\mysql-5.7.19-winx64\bin>mysql -uroot -pEnter password: ************Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.7.19Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql> set password=password(‘123456‘);Query OK, 0 rows affected, 1 warning (0.00 sec)
修改root密碼後,就可以在mysql中正常執行其他的命令了。可以試試看是否能執行sql命令。
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.00 sec)mysql> create database test;Query OK, 1 row affected (0.00 sec)mysql> use test;Database changedmysql> create table a1(a int, b int);Query OK, 0 rows affected (0.25 sec)mysql> insert into a1 values(1,2), (3, 4), (5, 6);Query OK, 3 rows affected (0.08 sec)Records: 3 Duplicates: 0 Warnings: 0mysql> select * from a1;+------+------+| a | b |+------+------+| 1 | 2 || 3 | 4 || 5 | 6 |+------+------+3 rows in set (0.00 sec)mysql>
這樣就裝好了MySQL資料庫。
Windows下安裝配置免安裝MySQL5.7伺服器