mysql用户可免密码登录问题处理解决

这篇具有很好参考价值的文章主要介绍了mysql用户可免密码登录问题处理解决。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

参考文章:点击跳转

现象描述

任意用户可登录MySQL数据库。如下面操作。会发现,此时登录后无法查看到正常的全部数据库,只能看到系统默认的测试数据库test和信息库infomation_schema。

else@linux-ctc7:~> mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.73-community MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.00 sec)

分析

正常登录该数据库,查看用户表,第四列里面,host为localhost,用户为空,密码为空。导致在本地登陆的时候除了root的账户外,其他账号不需要密码即可登陆,并且影响host为%的用户登陆。

else@linux-ctc7:~> mysql -uroot -pmysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.1.73-community MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user,password from user;
+------------+------+-------------------------------------------+
| host       | user | password                                  |
+------------+------+-------------------------------------------+
| %          | root | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| linux-ctc7 | root |                                           |
| 127.0.0.1  | root |                                           |
| localhost  |      |                                           |
| linux-ctc7 |      |                                           |
+------------+------+-------------------------------------------+
5 rows in set (0.00 sec)

mysql> 

解决

删除空用户。然后重启数据库。不重启数据库不生效。文章来源地址https://www.toymoban.com/news/detail-637494.html

mysql> select host,user from user;
+------------+------+
| host       | user |
+------------+------+
| %          | root |
| 127.0.0.1  | root |
| linux-ctc7 |      |
| linux-ctc7 | root |
| localhost  |      |
| localhost  | test |
+------------+------+
6 rows in set (0.00 sec)
mysql> delete from user where host='localhost' and user='';
Query OK, 1 row affected (0.00 sec)
mysql> delete from user where host='linux-ctc7' and user='';
Query OK, 1 row affected (0.00 sec)

//不重启数据库不生效。重启后生效。
else@linux-ctc7:~> mysql -u else             ---重启数据库前仍可登录
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.1.73-community MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/o its affiliates. All rights reserved.
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>
linux-ctc7:/etc/init.d # ./mysql stop
Shutting down MySQL..                                                 done
linux-ctc7:/etc/init.d # ps -ef|grep mysql
root      5561  5490  0 09:03 pts/1    00:00:00 grep mysql
linux-ctc7:/etc/init.d # ./mysql start
Starting MySQL.                                                       done
linux-ctc7:/etc/init.d # mysql       ---重启数据库后,root用户无法直接连接。
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
else@linux-ctc7:~> mysql -u else     ---重启数据库后,普通用户无法直接连接。
ERROR 1045 (28000): Access denied for user 'else'@'localhost' (using password: NO)

到了这里,关于mysql用户可免密码登录问题处理解决的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【centos 7】 用户开机登录密码忘记解决办法

    1、重启系统,开机进入GRUB界面,在引导程序菜单上进行选择 2、按\\\"e\\\"键进入 3、用上下箭头翻到最后,编辑修改两处: 【ro改为rw】【LANG=en_US.UFT-8后面添加init=/bin/sh】 【若命令行显示LANG=en_US.UFT-8 可以修改为LANG=zh_CN.UFT-8】 【若命令行显示LANG=zh_CN.UFT-8 可以修改为LANG=en_US.UFT

    2024年02月09日
    浏览(25)
  • MySQL修改登录密码

    适用于可以登录进入mysql数据库,想修改密码或者提示密码过期 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement 如果忘记密码可以看Linux系统MySQL忘记登录密码-CSDN博客这篇文章 方法一: 方法二: 方法三: 方法四: 如果提示:ERROR 1819 (HY00

    2024年02月02日
    浏览(26)
  • Docker登录MySQL,密码正确却提示密码错误

     当我输入了正确的MySQL密码的时候确提示我密码错误: 这是由于之前的挂载点的数据没有删除干净,删除掉宿主机下的mysql_master文件即可

    2024年01月22日
    浏览(57)
  • windows上Mysql登录步骤(忘记密码登录步骤)

    一、记得密码情况 1、cmd以管理员身份进入命令提示符窗口 2、输入net start mysql启动mysql服务 3、输入mysql -uroot -p+密码 进入mysql   二、若忘记密码进入方式(修改密码的方式) 1、以管理员身份进入后输入net stop mysql关闭mysql服务 2、输入mysqld --console --skip-grant-tables --shared-memor

    2024年02月05日
    浏览(26)
  • 解决“Can‘t connect to MySQL server on ‘localhost:3306‘ (10061)“MySQL登录报错问题

    1.按下”Win“+”R键“打开运行 2.输入” services.msc“ 3.找到MYSQL一项,右键点击属性 4.在属性中:将“启动类型”改为“自动” 5.在属性中:点击“服务状态”下的“启动”后,MySQL便可以正常登录。   1.按下“Win+R”键打开运行 2.输入\\\"cmd\\\"打开控制台,打开控制台后,在控制

    2024年02月07日
    浏览(37)
  • jenkins忘记用户名以及登录密码的解决方法

    1. 进入到安装jenkins路径,找到jenkins安装的配置文件 config.xml  比如我的jenkins安装路径如下图: 2. 打开config.xml文件夹,搜索到useSecurity 将useSecurity的属性改为false 如下图所示:  然后重启jenkins server,然后就可以进入到jenkins主主主页面了。 3. 进入系统管理的管理用户就可以

    2024年02月04日
    浏览(34)
  • mysql8.0更改用户密码

    1、mysql 启动命令 : mysql -uroot -p 2、mysql版本 查看命令: select version(); image.png 3、查看用户名对应的host 命令 : select user,host from user; image.png 4、修改用户的密码: alter user \\\'用户名\\\'@\\\'hostname\\\' identified by \\\'newpwd\\\'; ---‘用户名’是要修改的用户名,hostname是user对应的host,‘newpwd’是

    2023年04月08日
    浏览(23)
  • mysql 8.0版本更换用户密码

    1、首先 cmd 进入命令行  2、查询版本号 3、看一下数据库 4、使用mysql即可 5、进行查询 user、host 6、修改root的密码 7、刷新权限

    2024年02月11日
    浏览(36)
  • 处理普通用户安装启动mysql报Can‘t find error-message file‘usrsharemysqlerrmsg.sys‘ 问题

    操作系统:centos7 mysql版本:5.7.29 使用普通用户安装完成以后,启动mysql: /data/mysql/usr/sbin/mysqld --defaults-file=/data/mysql/etc/my.cnf --user=dongzw 日志中报: [ ERROR ] Can’t find error-message file \\\'/usr/share/mysql/ errmsg.sys’ . Check error-message file location and ‘lc-messages-dir’ configuration directive. 大概

    2024年02月15日
    浏览(30)
  • MySQL 8.0.31 登录提示caching_sha2_password问题解决方法

    MySQL 8.0.31 使用了 caching_sha2_password 作为默认的身份验证插件,这可能导致一些旧的客户端和库无法连接到服务器。以下是一些解决此类问题的常见步骤和建议: 确保MySQL服务正在运行:首先,确保你的MySQL服务器实例正在运行。你可以使用系统的服务管理工具来检查。 更新你

    2024年02月12日
    浏览(33)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包