mysql 8.0.19 winx64安裝及修改初始密碼

本文爲大家分享了mysql 8.0.19 winx64安裝教程,供大家參考,具體內容如下

1. 下載mysql-8.0.19-winx64

1.1 進入地址:https://dev.mysql.com/downloads/mysql/

 

 

1.2 解壓zip包,並將解壓文件 mysql-8.0.19-winx64 文件放在想放的位置,比如 D 盤下,如圖:

 

 

1.3 配置環境變量(目的是爲了避免在CMD窗口下操作時反覆切換路徑)

在Path下添加 D:\mysql-8.0.19-winx64\bin

 

 

環境變量設置好之後,以後重新打開CMD或者Windows Powershell,就可直接輸入mysql登陸了,而不用再切換到mysql的bin目錄再執行指令了。

1.4 無需編寫my.ini配置文件(注意)

現在新版的mysql安裝好之後已經沒有my.ini(或my-default.ini)文件了。而且我們也不需要額外的自己添加,因爲添加了之後有可能會導致無法啓動mysql的情況,本人已試過。因爲之前網上很多的博客教程都會說要添加my.ini(或my-default.ini)文件,但是我們現在不需要添加了。

 

 

2. MySQL的初始化及服務安裝

2.1 按“win”鍵打開開始菜單,在搜索框中輸入“cmd”,在搜索結果中選中“命令提示符”程序,右鍵選擇“以管理員身份運行”

 

 

2.2 初始化

用管理員權限打開CMD或者Windows Powershell
使用命令:mysqld --initialize --console
使用CMD命令操作後如下:

 
  1. C:\Windows\system32>D:\Python\mysql-8.0.12-winx64\bin\mysqld --initialize --console
  2. 2018-09-13T14:36:55.758742Z 0 [System] [MY-013169] [Server] D:\Python\mysql-8.0.12-winx64\bin\mysqld (mysqld 8.0.12) initializing of server in progress as process 3104
  3. 2018-09-13T14:37:12.072904Z 5 [Note] [MY-010454] [Server] A temporary **password isgenerated for root@localhost: `4P!w2fqBruGi`**
  4. 2018-09-13T14:37:23.274980Z 0 [System] [MY-013170] [Server] D:\Python\mysql-8.0.12-winx64\bin\mysqld (mysqld 8.0.12) initializing of server has completed

記錄下密碼,這裏的密碼是4P!w2fqBruGi,密碼是隨機生成的每個人都不一樣,此處生成的密碼在後面修改密碼時要用。

2.3 安裝mysql服務

使用命令: mysqld --install

 
  1. C:\Windows\system32>D:\Python\mysql-8.0.12-winx64\bin\mysqld --install
  2. Service successfully installed.

2.4 啓用服務

使用命令: net start mysql

 
  1. C:\Windows\system32>D:\Python\mysql-8.0.12-winx64\bin>net start mysql
  2. MySQL 服務正在啓動 ..
  3. MySQL 服務已經啓動成功。

2.5 修改密碼

輸入命令登陸: mysql -u root -p
輸入剛纔保存的密碼,如 4P!w2fqBruGi
使用命令: ALTER USER ‘root'@‘localhost' IDENTIFIED WITH mysql_native_password BY ‘新密碼';
注意密碼一定要6位數以上
比如我設置的密碼是123456



 
  1. D:\Python\mysql-8.0.12-winx64\bin>mysql -u root -p
  2. Enter password: ************
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 8
  5. Server version: 8.0.12
  6.  
  7. mysql> ALTER user 'root'@'localhost' IDENTIFIED BY '123456'
  8. -> ;
  9. Query OK, 0 rows affected (1.98 sec)

2.6 使用新密碼登陸

使用命令:mysql -u root -p

 
  1. D:\Python\mysql-8.0.12-winx64\bin>mysql -u root -p
  2. Enter password: ******
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 10
  5. Server version: 8.0.12 MySQL Community Server - GPL
  6.  
  7. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  8.  
  9. Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.
  12.  
  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  14.  
  15. mysql>

分享:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章