How can I set a user to a specific role via drush? In my case I want to give the role of administrator to the user.
drush help user-add-role Add a role to the specified user accounts. Examples: drush user-add-role "power user" 5,user3 Add the "power user" role to the accounts with name, id, or email 5 or user3, uids 2 --uid=2,3 --name=someguy,somegal and 3, names someguy and somegal, and email address of email@example.com --firstname.lastname@example.org Arguments: role The name of the role to add users (optional) A comma delimited list of uids, user names, or email addresses. Options: --mail=<email@example.com> A comma delimited list of user mail addresses of users to operate on. --name=<foo> A comma delimited list of user names of users to operate on. --uid=<3,5> A comma delimited list of uids of users to operate on. Aliases: urol
So, for your use case:
drush user-add-role administrator USERNAME
First you will need to get the user's id (UID) in the users table like this:
drush sqlq 'select * from users \Gamma'
My uid I wanted was
uid = 444
Then get the role id that you want assigned to that user by doing this:
drush sqlq 'select * from role'
Administrator role is rid = 3
Now I have my uid and rid, I do the following:
drush sqlq 'insert into users_roles (uid, rid) values (444, 3);'