windows下安裝mysql8並修改密碼


MySQL下載地址:http://dev.mysql.com/downloads/mysql/

Windows下安裝MySQL

我下的是最新版的MySQL,解壓后,目錄如下:

1.進入dos的命令行,一定要用administrator進入。
2.進入MySQL的bin目錄,輸入mysqld –install可以安裝MySQL

cd D:\idea\mysql-8.0.18-winx64\mysql-8.0.18-winx64\bin
D:
D:\idea\mysql-8.0.18-winx64\mysql-8.0.18-winx64\bin
D:\idea\mysql-8.0.18-winx64\mysql-8.0.18-winx64>mysqld -install
Service successfully installed.

3.輸入以下命令,可以初始化MySQL數據庫,初始化了之后,會打印出MySQL的默認生成的密碼,下面標紅了的就是默認生成的密碼。

D:\idea\mysql-8.0.18-winx64\mysql-8.0.18-winx64>mysqld --initialize --user=root --console
2019-12-20T02:28:44.093039Z 0 [System] [MY-013169] [Server] D:\idea\mysql-8.0.18-winx64\mysql-8.0.18-winx64\bin\mysqld.exe (mysqld 8.0.18) initializing of server in progress as process 7500
2019-12-20T02:28:51.796888Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 4IfH4*eywsg=

初始化了以后,可以看到MySQL目錄下,多了data目錄
4.啟動MySQL服務

D:\idea\mysql-8.0.18-winx64\mysql-8.0.18-winx64>net start mysql
MySQL 服務正在啟動 ..
MySQL 服務已經啟動成功。

5.使用默認生成的密碼,進入mysql

D:\idea\mysql-8.0.18-winx64\mysql-8.0.18-winx64>mysql -u root -p4IfH4*eywsg=
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.18

Copyright (c) 2000, 2019, 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>

6.修改密碼

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';
Query OK, 0 rows affected (0.01 sec)

7.退出,修改成功


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM