如何使用Drush从命令行更改用户密码?

有帮助吗?

解决方案

在drush 9中,命令是

drush user:password USERNAME "SOMEPASSWORD"

使用命令名称别名 user-passwordupwd.

在Drush 8(和更早)中,命令是

drush user-password USERNAME --password="SOMEPASSWORD"

使用命令名称别名 upwd.

https://drushcommands.com/drush-9x/user/user:Password/https://drushcommands.com/drush-8x/user/user-password/

其他提示

您可以执行 drush uli, ,这将生成一次一次登录链接。默认情况下,它为管理员提供一次性登录链接。

如果您执行 drush uli some-username, ,这将为该用户生成一次时间登录链接。

更新:

您也可以使用 drush upwd 用于更新密码。这样用 drush upwd --password=<new password> <some-username>

如果您使用的是Drush 4,则可以使用user-password命令。

drush user-password usernamehere --password="newpasswordhere"

$ drush帮助用户password(re)设置了用指定名称的用户帐户的密码。

示例:drush用户 - password someuser -password =“正确的马电池”设置了用户名someuser的密码。 @See xkcd.com/936

参数:命名要修改的帐户的名称。

选项:-password =该帐户的新密码。必需的。

别名:UPWD

在Drush 9中(建议用于> Drupal 8.4),这略有不同:

drush upwd USERNAME PASSWORD

还有另一种重置密码的方法。您可以使用 drush uli "username" 在终端中提供重置链接,使用链接可以登录并更改密码。

如果指定 -l http://localhost (位于Localhost是您的主机的位置),然后终端将为您自动打开Web浏览器。

在新版本的Drush(在Drush 9 Drupal> 8.5中)中不适用于

drush user-password USERNAME --password="SOMEPASSWORD"

肯定是

drush user-password USERNAME SOMEPASSWORD

例如(更改root用户的密码)

drush user-password root MyPass0302

Drupal控制台

drupal user:password:reset

然后输入UserId,
然后输入新密码。

好好享受。

更新

在drush> 9

drush upwd USERNAME PASSWORD

如果您对服务器具有访问权限,请使用Drupal root Directory并运行:

drush upwd --password="myNewSecretPassword" "admin"

资源: https://www.drupal.org/node/44164

如果我们对Drush不了解,那么我们可以从用户表中的数据库更改密码。我们将编辑密码并选择MD5,然后可以更改密码。

请注意,此命令已在Drush 9.x中发生了变化,但可以记录在记录中 这里

因此,语法看起来像这样:

drush user:password someuser "correct horse battery staple"

例如,在用户的“ bjenkins”上是:

drush user:password bjenkins "newReallyComplexPassword123!"

您也可以添加 --notify 命令将此密码通知用户将其更改为其注册电子邮件。

许可以下: CC-BY-SA归因
scroll top