hugo-teek is loading...

排错

最后更新于:

mysql排错

案例:mysqladmin修改默认密码是时报错-2024.4.6==(已解决)==

故障环境:

1mysql-5.7.29
2centos7.6 1810
1mysqladmin -uroot -p'LufavlMka6,!'   password magedu

自己这里测试时报错了:

 1[root@vm-template ~]#awk '/temporary password/{print $NF}' /data/mysql/mysql.log
 2?Ny,T;oKg5t>
 3[root@vm-template ~]#
 4
 5mysqladmin -uroot -p'?Ny,T;oKg5t>'   password magedu
 6
 7[root@vm-template ~]#mysqladmin -uroot -p'?Ny,T;oKg5t>'   password magedu
 8mysqladmin: [Warning] Using a password on the command line interface can be insecure.
 9mysqladmin: connect to server at 'localhost' failed
10error: 'Your password has expired. To log in you must change it using a client that supports expired passwords.'
11[root@vm-template ~]#

📌 gpt

1[root@vm-template ~]#mysqladmin -uroot -p'?Ny,T;oKg5t>'   password magedu
2mysqladmin: [Warning] Using a password on the command line interface can be insecure.
3mysqladmin: connect to server at 'localhost' failed
4error: 'Your password has expired. To log in you must change it using a client that supports expired passwords.'

当MySQL用户的密码过期时,您将无法用常规方法或常规客户端更改密码,因为它们可能不支持密码过期功能。在这种情况下,您需要使用支持密码过期的客户端来重置密码。对于MySQL,通常意味着您需要直接连接到MySQL服务器并通过命令行进行操作。

请按照以下步骤操作:

  1. 使用支持密码过期的MySQL客户端登录。打开终端,并尝试:

    1mysql -uroot -p
    
  2. 系统会提示您输入密码,这时输入您的旧密码 ?Ny,T;oKg5t>

  3. 如果MySQL版本支持,登录后您可能会被提示修改密码。如果是,请按提示操作。

  4. 如果没有自动提示,或者提示不起作用,您可以在MySQL提示符下运行以下命令来设置新密码:

    1SET PASSWORD = PASSWORD('您的新密码');
    

    或者,若MySQL版本为5.7.6或更新,应使用以下命令:

    1ALTER USER 'root'@'localhost' IDENTIFIED BY '您的新密码';
    2
    3ALTER USER 'root'@'localhost' IDENTIFIED BY 'xyy520';
    

    请确保将 '您的新密码' 替换为您想要的新密码。

  5. 执行完上述命令后,退出MySQL:

    1quit
    
  6. 现在您应该可以使用新密码通过mysqladmin或其他客户端工具连接到MySQL了。

如果您在这个过程中遇到任何问题,请再次检查您的MySQL服务器的版本和配置,因为不同版本可能需要略有不同的操作。

📌 再次测试(测试OK,符合预期)

 1[root@vm-template ~]#mysql -uroot -p
 2Enter password: 
 3Welcome to the MySQL monitor.  Commands end with ; or \g.
 4Your MySQL connection id is 20
 5Server version: 5.7.29
 6
 7Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
 8
 9Oracle is a registered trademark of Oracle Corporation and/or its
10affiliates. Other names may be trademarks of their respective
11owners.
12
13Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
14
15mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'xyy520';
16Query OK, 0 rows affected (0.00 sec)
17
18mysql> \q
19Bye
20[root@vm-template ~]#mysql -uroot -pxyy520
21mysql: [Warning] Using a password on the command line interface can be insecure.
22Welcome to the MySQL monitor.  Commands end with ; or \g.
23Your MySQL connection id is 21
24Server version: 5.7.29 MySQL Community Server (GPL)
25
26Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
27
28Oracle is a registered trademark of Oracle Corporation and/or its
29affiliates. Other names may be trademarks of their respective
30owners.
31
32Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
33
34mysql> show databases;
35+--------------------+
36| Database           |
37+--------------------+
38| information_schema |
39| mysql              |
40| performance_schema |
41| sys                |
42+--------------------+
434 rows in set (0.00 sec)
44
45mysql> \q
46Bye
47[root@vm-template ~]#
推荐使用微信支付
微信支付二维码
推荐使用支付宝
支付宝二维码
最新文章

文档导航