Heim  >  Fragen und Antworten  >  Hauptteil

Zurücksetzen von Benutzerkennwörtern in MySQL 8.0: Eine Schritt-für-Schritt-Anleitung

Meine Fragen und Details

Ich möchte das Passwort eines Benutzers in MySQL8.0 ändern, aber fast keine der Online-Methoden scheint zu funktionieren.

Hier sind meine mysql.user-Tabellendetails:

mysql> select user, host from user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| Excalibur        | %         |
| yyy              | %         |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+

Was habe ich getan

Ich habe folgende Befehle ausprobiert:

alter user 'yyy'@'%' identified with mysql_native_password by '12345';

und erhielt die Fehlermeldung:

ERROR 1396 (HY000): Operation ALTER USER failed for 'yyy'@'%'

Ich habe auch versucht, die mysql.user-Tabelle selbst zu manipulieren:

update user set authentication_string=sha1('12345') where user = 'yyy' ;
flush privileges;

Obwohl es funktioniert, kann ich mich nicht mit dem Passwort 12345 bei yyy anmelden. Dann habe ich einen Blick auf die Tabelle geworfen und es sah wirklich seltsam aus:

+------------------+-----------+------------------------------------------------------------------------+
| user             | host      | authentication_string                                                  |
+------------------+-----------+------------------------------------------------------------------------+
| Excalibur        | %         | $Arrreee5$tE.D2|7^FTRYjmg1APzveuTWyJ1BaO2al1GKvO3UJO6ZlX06jqbNkT5 |
| yyy              | %         | 8cb2237d0679ca88db6464eac60da96345513964                               |
| mysql.infoschema | localhost | $Arrreee5$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.session    | localhost | $Arrreee5$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
...

P粉724737511P粉724737511292 Tage vor489

Antworte allen(1)Ich werde antworten

  • P粉022285768

    P粉0222857682024-01-02 09:59:10

    对于 MySQL 8.0

    普通用户使用以下命令更改密码

    ALTER USER 'userName'@'localhost' IDENTIFIED BY 'New-Password-Here';

    root用户使用以下命令更改密码

    P.S 检查使用带有“$A$005$”的密码,应该使用 caching_sha2_password 身份验证插件,如果没有“WITH caching_sha2_password”将不适用于 root 用户。如果是一般用户 需要授予权限。

    ALTER USER 'userName'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'New-Password-Here';

    Antwort
    0
  • StornierenAntwort