XAMPP重置MySQL密碼


  找到XAMPP的安裝位置,這里以我的為例:C:\xampp

  那么MySQL的路徑:C:\xampp\mysql

  phpMyAdmin的路徑:C:\xampp\phpMyAdmin

修改MySQL密碼

第一步:

  通過XAMPP控制面板(XAMPP Control Panel)關閉MySQL服務(stop)。

第二步:

  打開命令行終端,切換到目錄:C:\xampp\mysql\bin

C:\Windows\System32>cd C:\xampp\mysql\bin

C:\xampp\mysql\bin>mysqld --skip-grant-tables 2018-03-28 11:09:05 4200 [Note] mysqld (mysqld 10.1.19-MariaDB) starting as process 5716 ...

  輸入命令后,窗口會進入無法操作的狀態,此時MySQL也會啟動,保持命令行終端窗口的狀態,不要關閉。

第三步:

  打開另一個命令行終端,同樣切換到目錄:C:\xampp\mysql\bin

  依次輸入命令如下:

C:\xampp\mysql\bin>mysql.exe -u root     # 以root用戶登陸               
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.19-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> use mysql          # 使用mysql數據庫
Database changed
MariaDB [mysql]> update user set password=PASSWORD('root') where user='root';       # 更改密碼 
Query OK, 0 rows affected, 3 warnings (0.00 sec)
Rows matched: 3  Changed: 0  Warnings: 3

MariaDB [mysql]> flush privileges;      # 刷新權限
Query OK, 0 rows affected, 12 warnings (0.02 sec)

  這樣我們就成功的修改了MySQL的密碼,這里設置為root,但是我們還需要修改phpMyAdmin的配置文件中的數據庫連接密碼,保證能正常連接數據庫。

修改phpMyAdmin配置文件

  修改C:\xampp\phpMyAdmin\config.inc.php中的為你想設置的密碼。

$cfg['Servers'][$i]['password'] = 'root';

  重啟MySQL服務,便能使用新設置的密碼使用了。


免責聲明!

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



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