標籤:wpa foreign welcome 簡單 generated Owner 保護功能 creating not
1.下載.MySQL
http://dev.mysql.com/downloads/mysql/
下載windows的zip包,解壓後,添加path路徑bin, 系統內容變數->path->D:\mysql-5.7.19-winx64\bin 修改設定檔:D:\mysql-5.7.19-winx64\my-default.ini(如果沒有可以自己手動添加) 在裡面添加
[mysqld] basedir=D:\mysql-5.7.19-winx64 #mysql所在目錄
datadir=D:\mysql-5.7.19-winx64\data #mysql所在目錄\data
2.安裝 用管理員方式開啟命令列,找到mysql的bin目錄,將工作目錄cd到該目錄下,然後使用命令mysqld -install
D:\mysql-5.7.19-winx64\bin>mysqld -install
Service successfully installed.
安裝成功之後就可以啟動服務: 進入在bin目錄下操作:net start mysql
如果出現以下錯誤:
D:\mysql-5.7.19-winx64\bin>net start mysqlMySQL 服務正在啟動 .MySQL 服務無法啟動。服務沒有報告任何錯誤。請鍵入 NET HELPMSG 3534 以獲得更多的協助。
解決辦法: MySQL 服務無法啟動一般都是my-default.ini設定檔沒有配置好(有的也叫my.ini),最主要就是配置basedir和datadir。若有其餘問題請轉至MySQL在windows的my-default.ini配置查看my-default.ini的配置意義。 mysqld --initialize 先初始化data目錄(此語句會再次根據my-default.ini的內容進行初始化設定參數)。
D:\mysql-5.7.19-winx64\bin>mysqld --initializeD:\mysql-5.7.19-winx64\bin>net start mysqlMySQL 服務正在啟動 .MySQL 服務已經啟動成功。
輸入mysqld --initialize-insercure產生無密碼的使用者(貌似無效)。 初始化並重啟成功後,查看data檔案夾下的err檔案,應該有類似內容:
2017-09-07T09:37:03.899377Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2017-09-07T09:37:04.569889Z 0 [Warning] InnoDB: New log files created, LSN=457902017-09-07T09:37:04.679042Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2017-09-07T09:37:04.772602Z 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: 1bc80410-93b0-11e7-9439-00fff97c2448.2017-09-07T09:37:04.788195Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.2017-09-07T09:37:04.803789Z 1 [Note] A temporary password is generated for [email protected]: jole/W*_Z6rn
3.驗證是否安裝成功
如果看到說MySQL 服務正在啟動 .一直這樣顯示,直接斷行符號就行了,會顯示啟動成功。服務啟動成功之後,就可以登入了,mysql -u root -p斷行符號之後,提示輸入密碼,輸入上面產生的隨機密碼,
會顯示:
D:\mysql-5.7.19-winx64\bin>mysql -u root -pEnter password: ************Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 6Server 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.
4.修改密碼
對於windows平台來說安裝完MySQL資料庫後,系統就已經預設產生了許可表和賬戶,你不需要像在Unix平台上那樣執行 mysql_install_db指令碼來產生帳戶和相應許可權許可表。但是如果不是用MSI格式來安裝MySQL的話,就需要在安裝完以後,手動給root帳戶添加新密碼,因為預設情況下的root沒有開啟密碼保護功能,如果不重新賦予root帳戶密碼,那麼許多非原生串連將無法成功。
方法1:用SET PASSWORD命令,具體更新密碼步驟如下:
c:>mysql -u rootmysql>set password for ‘root‘@‘localhost‘=password(‘newpasswd‘)mysql>set password for ‘root‘@‘%‘=password(‘newpasswd‘) //本條可選
通過以上設定,root的密碼將變為newpasswd這樣就完成了根使用者root密碼的設定工作。
方法2:用mysqladmin
mysqladmin -u root password "newpass"
如果root已經設定過密碼,採用如下方法:
mysqladmin -u root password oldpass "newpass"
方法3: 用UPDATE直接編輯user表
mysql -u rootmysql> use mysql;mysql> UPDATE user SET Password = PASSWORD(‘newpass‘) WHERE user = ‘root‘;mysql> FLUSH PRIVILEGES;
在丟失root密碼的時候,可以這樣
mysqld_safe --skip-grant-tables&mysql -u root mysqlmysql> UPDATE user SET password=PASSWORD("new password") WHERE user=‘root‘;mysql> FLUSH PRIVILEGES;
方法4:用ALTER USER的方法編輯user表
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘password‘
就這麼簡單就完成了MySQL資料庫預設密碼的修改,預設密碼修改了之後大家就可以進行更多的操作了。
4.退出資料庫
MySQL退出的三種方法:
mysql > exit;mysql > quit;mysql > \q;
MySQL安裝(windows版本)