XAMPP 裡的 MariaDB/MySQL 重設 root 密碼
在 利用 Apache 的 Virtual Host 功能來架設虛擬網站文章提到,利用 XAMPP 架設網站是非常簡單的事, XAMPP 包含了 Apache + MariaDB + PHP + Perl ,而且在 Windows、Linux、OS X ( MAC PC ) 都可以安裝,但安裝 XAMPP 好後,MariaDB/MySQL 的 root 密碼預設是空白的,這涉及了資訊安全的議題,要如何修改呢? 改了以後 phpMyAdmin 要作那些相對應的修改,這常是面臨的一件事,記錄起來以方便日後參考。
- 執行 xampp_shell
先確認 MariaDB/MySQL 有啟動,在 XAMPP 的 Control Panel 裡,點選 Shell ,這時會提示會產生 xampp_shell.bat ,然後進入 shell 模式
- 執行 mysqladmin 修改 root 密碼
# mysqladmin --user=root password "newPassword"
用一張圖來顯示所有的動作如下:
因為修改了 root 的密碼,這時候 phpMyAdmin 是登不進去的,所以要修改 \xampp\phpMyAdmin\config.inc.php ,先找到下面程式段
/* Authentication type and info */ $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = ''; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['AllowNoPassword'] = true; $cfg['Lang'] = '';
修改成下面這樣
/* Authentication type and info */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = 'newPassword'; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['AllowNoPassword'] = false; $cfg['Lang'] = '';
再重新登入 phpMyAdmin 就可以了。
你必須 登入 才能發表評論。