注:
- 管理員下運行 cmd
- bin 目錄下
-
在 my.ini 下添加
skip-grant-tables
, 可免密登錄
-
設置密碼
D:\mysql-5.7.35\bin>net start mysql
MySQL 服務正在啟動 .
MySQL 服務已經啟動成功。
D:\mysql-5.7.35\bin>mysql -u root -p
Enter password: # 此處直接回車,不輸入密碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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> update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
host:確定要操作的數據庫在哪台電腦上,比如上圖的localhost代表的是本機,如果要操作的是別人的電腦,就需要輸入其他的IP地址
- 注掉
skip-grant-tables
- 重啟 MySQL 即可
mysql> exit
Bye
D:\mysql-5.7.35\bin>net stop mysql
MySQL 服務正在停止.
MySQL 服務已成功停止。
D:\mysql-5.7.35\bin>net start mysql
MySQL 服務正在啟動 .
MySQL 服務已經啟動成功。
- 回到 Navicat 輸入密碼即成功解決