1. 解壓壓縮包,放置到任意目錄
注意目錄最好是英文
這是我的目錄:
D:\Python\mysql-8.0.12-winx64\
2. 初始化
用管理員權限打開CMD或者Windows Powershell
使用命令:mysqld --initialize --console
使用CMD命令操作如下:
C:\Windows\system32>D:\Python\mysql-8.0.12-winx64\bin\mysqld --initialize --console
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
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:\Python\mysql-8.0.12-winx64\bin\mysqld (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:\Windows\system32>D:\Python\mysql-8.0.12-winx64\bin\mysqld --install
Service successfully installed.
4. 啟用服務
使用命令: net start mysql
C:\Windows\system32>D:\Python\mysql-8.0.12-winx64\bin>net start mysql
MySQL 服務正在啟動 ..
MySQL 服務已經啟動成功。
5. 修改密碼
- 輸入命令登陸: mysql -u root -p </br>
- 輸入剛才保存的密碼
- 使用命令: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密碼';</br>
- 注意密碼一定要6位數以上
- 我設置的密碼是111111 ,告訴你們沒關系
D:\Python\mysql-8.0.12-winx64\bin>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:\Python\mysql-8.0.12-winx64\bin>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.配置環(huán)境變量:
- 進入 計算機--高級系統(tǒng)設置--高級--環(huán)境變量
- 然后新建系統(tǒng)變量
- 變量值改為自己mysql解壓的路徑
- 變量名:MYSQL_HOME
- 變量值:D:\Python\mysql-8.0.12-winx64\
- path里添加:%MYSQL_HOME%\bin;(分號不要忘記)
- 重新打開CMD或者Windows Powershell轧飞,之直接輸入mysql登陸