简体   繁体   English

如何由用户自己更改 mysql 用户密码而不是 admin/root?

[英]How to change mysql user password by the user himself not by admin/root?

How to change mysql user password by the user himself not by admin/root?如何由用户自己更改mysql用户密码而不是 admin/root?
I mean, for a user john -我的意思是,对于用户john -

  1. the dba creates the user john and sets the default password to john1234 dba 创建用户john并将默认密码设置为john1234
  2. now john is able to connect to mysql server.现在john能够连接到 mysql 服务器。
  3. john now wants to change his password to john4321 , so that even the dba admin is not aware of the changed password. john现在想将他的密码更改为john4321 ,这样即使 dba 管理员也不知道更改后的密码。
  4. infact, in my usecase, the root password is lost (hhmmm, and i think there is no way to recover it from the encrypted password string).事实上,在我的用例中,根密码丢失了(hhmmm,我认为没有办法从加密的密码字符串中恢复它)。 But I am still fine if john can change his password himself.但如果john可以自己更改密码,我还是没问题的。

Is it possible?是否可以?

Normally your should be able to change your own password.通常您应该能够更改自己的密码。 The command is命令是

SET PASSWORD = PASSWORD('john4321');

The only way to know whether you have the right is to try.要知道你是否有权利的唯一方法就是尝试。
If you have a few ideas what the old password was you could compare the result of如果您知道旧密码是什么,您可以比较以下结果

SELECT PASSWORD ('possible old password');

to the hash in the table mySQL.user, if you have access to it.到表 mySQL.user 中的 hash,如果您有权访问它。
21/02/2022 I have just created a user with no rights whatsoever. 21/02/2022 我刚刚创建了一个没有任何权限的用户。 When I logged in as the new user I successfully ran the command:当我以新用户身份登录时,我成功运行了命令:

SET PASSWORD = PASSWORD('1234');

and when I relogged in with password 1234 it worked.当我使用密码 1234 重新登录时,它起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM