小悠哉 2023-03-22 09:29 采纳率: 100%
浏览 38
已结题

MySQL 取消免密登陆失败

MySQL8.0设置密码后,仍然可以免密登陆
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye
[root@bogon mysql]# 
[root@bogon mysql]# 
[root@bogon mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.31-commercial MySQL  Server - Commercial

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> 
mysql> select user,host,authentication_string from mysql.user ;
+------------------+-----------+------------------------------------------------------------------------+
| user             | host      | authentication_string                                                  |
+------------------+-----------+------------------------------------------------------------------------+
| mysql.infoschema | localhost | $A$005$THISISATANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.session    | localhost | $A$005$THISISACOLTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| mysql.sys        | localhost | $A$005$THISISACOMBINTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| root             | localhost | $A$005$YS&{@VTMi8|mAXhxfxDk/seIDuFPtc66RqTN/ |
+------------------+-----------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)

mysql> exit


操作系统:centos7 、MySQL版本:8.0.31
为什么设置了MySQL密码,还能免密登陆呢?
  • 写回答

3条回答 默认 最新

  • 小悠哉 2023-03-22 10:39
    关注

    我擦,居然是我的密码有bug。。。

    1.设置密码为“Newpassword”,一切正常,没有密码不能登陆。

    mysql> 
    mysql> alter user user() identified by 'Newpassword';
    Query OK, 0 rows affected (0.03 sec)
    
    mysql> 
    mysql> exit
    Bye
    [root@bogon mysql]# mysql
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    [root@bogon mysql]# mysql -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 40
    Server version: 8.0.31-commercial MySQL Server - Commercial
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> 
    

    2.修改密码为我想设置的密码,问题就又出现了,空密码或者我设置的密码都可以正常登陆。

    mysql> 
    mysql> alter user user() identified by 'xxxxx';
    Query OK, 0 rows affected (0.02 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> exit
    Bye
    [root@bogon mysql]# mysql
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 41
    Server version: 8.0.31-commercial MySQL Server - Commercial
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> exit
    Bye
    [root@bogon mysql]# mysql -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 42
    Server version: 8.0.31-commercial MySQL Server - Commercial
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> 
    

    目前只试出来我自己的密码会出现这个问题。。。。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 3月30日
  • 已采纳回答 3月22日
  • 创建了问题 3月22日

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效