1、Windows下安裝mysql-8.0.12及修改初始密碼

曲~線發表於2018-09-13

1. 解壓壓縮包,放置到任意目錄

這是我的目錄:
D:Pythonmysql-8.0.12-winx64

2. 初始化

使用命令: –initialize –console

使用CMD命令操作如下:

C:Windowssystem32>D:Pythonmysql-8.0.12-winx64inmysqld --initialize --console
2018-09-13T14:36:55.758742Z 0 [System] [MY-013169] [Server] D:Pythonmysql-8.0.12-winx64inmysqld (mysqld 8.0.12) initializing of server in progress as process 3104
2018-09-13T14:37:12.072904Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 4P!w2fqBruGi
2018-09-13T14:37:23.274980Z 0 [System] [MY-013170] [Server] D:Pythonmysql-8.0.12-winx64inmysqld (mysqld 8.0.12) initializing of server has completed

記錄下密碼,後面修改密碼還要用</br>
在這裡:

[Server] A temporary password is generated for root@localhost: 4P!w2fqBruGi

最後面的 ==4P!w2fqBruGi== 就是密碼,密碼是隨機生成的每個人都不一樣

3. 安裝

使用命令: mysqld –install

C:Windowssystem32>D:Pythonmysql-8.0.12-winx64inmysqld --install
Service successfully installed.

4. 啟用服務

使用命令: net start mysql

C:Windowssystem32>net start mysql
MySQL 服務正在啟動 ..
MySQL 服務已經啟動成功。

5. 修改密碼

使用命令: ALTER USER `root`@`localhost` IDENTIFIED WITH mysql_native_password BY `新密碼`;

我設定的密碼是111111 ,告訴你們沒關係

D:Pythonmysql-8.0.12-winx64in>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.0.12

mysql> ALTER user `root`@`localhost` IDENTIFIED BY `111111`
    -> ;
Query OK, 0 rows affected (1.98 sec)

6. 使用新密碼登陸

使用命令:mysql -u root -p

D:Pythonmysql-8.0.12-winx64in>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 10
Server version: 8.0.12 MySQL Community Server - GPL

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

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

Type `help;` or `h` for help. Type `c` to clear the current input statement.

mysql>

7.配置環境變數:

  1. 進入 計算機–高階系統設定–高階–環境變數
  2. 然後新建系統變數
  3. 變數值改為自己mysql解壓的路徑
  4. 變數名:MYSQL_HOME
  5. 變數值:D:Pythonmysql-8.0.12-winx64
  6. path裡新增:%MYSQL_HOME%in;(分號不要忘記)

是否成功,請在下方留言

如果此文對你有幫助,可以在下方點贊或者點喜歡,謝謝支援


相關文章