How to get admin permissions for drupal user using drush

There are couple of ways to do it:

First, you can just add an appropriate permission to your user. But you have to know the ID of the administration role on your site. For example, this id is equals 3:
sudo drush sql-query "INSERT INTO users_roles (uid, rid) VALUES (29157, 3);"

The second way, you can just change the password of the main user, I have a hash for 123 password, just run this query and then you will be able to log to your site with 'admin' user and '123' password:
sudo drush sql-query "UPDATE users SET pass='$S$D.w4fp/UMSMPvuXW4ThkKL98pBPYi2SsjeGV2YmKfZrXjcfvL' WHERE uid = 1"

And the last one - you can write some php code in any drupal module in hook _init() to get admin permissions for this session, for example:

function mymodul_init() {
  global $user;
  $user = user_load(1);

Don't forget to clear drupal cache to make it work.
Then you can create a new user with an appropriate permissions.

Good luck!

Drupal 7


Добавить комментарий