Support & Downloads

Quisque actraqum nunc no dolor sit ametaugue dolor. Lorem ipsum dolor sit amet, consyect etur adipiscing elit.

s f

Contact Info
198 West 21th Street, Suite 721
New York, NY 10010
[email protected]
+88 (0) 101 0000 000
Follow Us

Client Portal (866) 963-0424

Recovering Administrator Access on Your Drupal Site


If you have lost your administrator password for your site, this article will help you recover access. The way most content management systems (CMS) stores authentication data, is within a MySQL database table usually named “user.” Passwords are usually encrypted using one way hashing algorithms such as SHA2 and sometimes made difficult to brute force with key derivation functions or salting. Some CMS has tools that you can use via SSH, and others require that you modify the database directly. This article will explain how you can reset the password for Drupal.

Using phpMyAdmin to run a query

In this article, there are many steps that require running a MySQL query on the database for your web site. If you are unfamiliar with MySQL, we recommend that you pay close attention when entering the query or contact us for assistance as you are able to cause damage to the site if a query is entered incorrectly. This section will provide instructions on how to run the queries mentioned in this article with the use of phpMyAdmin built into cPanel.

Before you run any query, first make sure that you are running the query on the correct database and that you have updated or added correct prefixes to the tables mentioned in a query. You can find this information by viewing the configuration file for the site, which contains the database name and table prefix.

 UPDATE `prefix_users` SET `user_pass` = MD5(‘password’) WHERE `user_login` = ‘admin’; 

The query above will change the password for the user “admin” to the password “password” on a CMS. Before you run the query, you must first update the query to match your environment. The prefix, identified as “prefix_” in the example, needs to be either removed or replaced depending on if your site uses a prefix. The password needs to be replaced. The username needs to be updated to your account login-if you do not know the account login, you can usually click on the table in phpMyAdmin to see what accounts exist.

Note: If you are copying and pasting the query, double check the single quotes (‘) and prime (`) are not replaced with smart quotes. The prime key is to the top left of the keyboard under the escape key and the single quote key is next to the return key typically on a us keyboard.

Once you have all the information above updated to match your environment, you can then run the query on the database.

  1. Login to cPanel.
  2. Under the databases section, click on phpMyAdmin.
  3. On the left side bar, click on the database for your site.
  4. On the top, click on the tab named SQL.
  5. Confirm that the “Run SQL query/queries on database user_db” matches the database name of your site.
  6. Enter the query, updated to match your environment.
  7. Once you have confirmed everything is right (you can click simulate query to see how many items will be affected), click on the “Go” button on the bottom right to execute the command.

Drupal

Drupal 7 and Drupal 8 has completely different authentication systems, they both require that you have access to SSH.

Version 7
  1. SSH into your account and change directory to the document root of your site.
  2. Run the following in SSH, replacing “password” with the password you like.

php ./scripts/password-hash.sh ‘password’

  1. You should receive something like the following.

password: password    hash: $S$DN8Za.ED7.56QpAXJ2G0KgcS1cnIy8EjVL9uVW8yqPwUtlLO1znj

  1. Copy the hash, which starts with a dollar sign.
  2. Follow the phpMyAdmin instructions to run the following with the hash you received.

 UPDATE `prefix_users` SET `pass` = '$S$DN8Za.ED7.56QpAXJ2G0KgcS1cnIy8EjVL9uVW8yqPwUtlLO1znj' WHERE `name` =’‘admin’; 

  1. Login with your new password.
Version 8 and 9
  1. SSH into your account and change directory to the document root of your site.
  2. Run the following in SSH, replacing “password” with the password you like.

php ./core/scripts/password-hash.sh ‘password’

  1. You should receive something like the following.

password: password    hash: $S$E1Ym0zPgB6sM9GkPRlk0PTBOM9MbQgGzkvINxMZu9SpaAdiiDjNN

  1. Copy the hash, which starts with a dollar sign.
  2. Follow the phpMyAdmin instructions to run the following with the hash you received. Note that this assumes the administrator’s account has the ID of 1. If the account you are changing the password for is a different ID, update the uid and cid from 1 to the proper ID.

 UPDATE `prefix_users_field_data` SET `pass` = '$S$E1Ym0zPgB6sM9GkPRlk0PTBOM9MbQgGzkvINxMZu9SpaAdiiDjNN' WHERE `uid` = 1;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>DELETE FROM `prefix_cache_entity` WHERE `cid` = 'values:user:1'; 

  1. Login with your new password.

Post a Comment