
有一台配置了 Drupal 的舊虛擬機,但我不記得管理員密碼了。密碼恢復過程向我發送了一個重置密碼的鏈接,但生成的頁面顯示“訪問被拒絕”。
然後我嘗試了直接編輯 MySQL 中的 Drupal 使用者表。這本來是可行的,除非安裝了 Salt 模組,因此哈希值無效。
我不知道從這裡該去哪裡;有任何想法嗎?
答案1
看來您已經解決了問題,但無論如何,這裡有一個答案。連接到 mysql 資料庫並執行以下操作:
- 從變數中選擇值,其中 name='salt';
- 更新使用者設定 pass=md5('newpassSALT') 其中 uid=1;其中 SALT 是上面提到的值。
密碼應重設為“newpass”。
答案2
MD5('newpassSALT')
我對中描述的方法沒有運氣接受的答案,這就是對我有用的。請注意,您需要用您自己的值替換以下內容:
/var/www/path/to/drupal
:Drupal 的安裝位置mynewpassword
:您想要的密碼drupaluser
:drupal資料庫用戶drupaldb
:Drupal 資料庫架構
一步步:
# cd /var/www/path/to/drupal
# scripts/password-hash.sh "mynewpassword"
password: mynewpassword hash: $S$C/mWw8UGcAyCwLDOiqRBOShJl8w2vVLsSzYvqCMuAg/LSncU16Iy
# mysql -u drupaluser -p
enter your password:
mysql> use drupaldb
Database changed
mysql> update users set pass='$S$C/mWw8UGcAyCwLDOiqRBOShJl8w2vVLsSzYvqCMuAg/LSncU16Iy' where uid=1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
答案3
您的 drupal 系統上是否有第二個可以使用的非管理員帳號?是否也使用預定的密碼?您可以直接編輯 mysql 表並將密碼從已知帳戶複製到管理員帳戶嗎?
答案4
你的資料庫結局錯誤! mysql.user表專門用於mysql帳號存取Drupal的資料庫。如果 drupal 說“存取被拒絕”,那麼它可能可以存取其資料庫,而您忘記了 drupal 的管理員密碼。我強烈推薦為此使用 phpMyAdmin。
1. Login to phpMyAdmin
2. Select the database which Drupal use from the drop-down menu on the left.
4. Click on the SQL tab.
5. In the text field on the page type the following text:
update users set pass=md5('NEWPASS') where uid = 1;
1的uid是admin,您可以透過更改此查詢中的uid來更改其他使用者使用的密碼。