当前位置:网站首页>Linux的mysql报ERROR 1045 (28000) Access denied for user ‘root‘@‘localhost‘ (using password NOYSE)
Linux的mysql报ERROR 1045 (28000) Access denied for user ‘root‘@‘localhost‘ (using password NOYSE)
2022-07-31 05:07:00 【m0_67402125】
(1)如果是最后的提示是NO则说明当前数据的登录需要使用密码,而此次登录时并没有使用密码登录,只需进行密码登录。
(2)如果使用密码登录时,报错YES,则说明当前用户的密码字段或者Host字段出现问题,则可先通过绕过密码的方式进行登录查看登录用户信息。
绕过密码登录
(1)如果mysql的版本是5.7以下,则直接在/etc文件夹下找到my.cnf,然后在[mysqld]字段下添加一行skip-grant-tables,保存完重启数据库,然后就可以直接使用mysql免密登录数据库。
(2)如果mysql的版本是5.7以上,在/etc文件夹下是找不到my.cnf文件的,所以只需要新建一个my.cnf,然后添加两行代码
[mysqld]
skip-grant-tables
保存完重启数据库,然后就可以直接使用mysql免密登录数据库。
修改用户密码
(1)免密登录之后,use mysql切换数据库,然后依次执行
update user set authentication_string = PASSWORD('new password') where User = 'username';
FLUSH PRIVILEGES;
第一句sql指令如果数据库版本低于5.7时,user表中的密码字段应该是password,所以需要将指令修改为
update user set password = PASSWORD('new password') where User = 'username';
(2)修改之后可以通过sql指令查看当前用户信息
Select Host, authentication_string from user where User = ‘username’;
此处需要特别说明,该表中的Host字段指示的是当前登录数据用户的主机ip,比如说Host字段中是localhost,那如果想登录数据库,则只能是本机登录,所以在做开发时需要将数据库的地址设置为localhost,如果想要远程访问,可以将Host改为想要进行访问的主机的ip地址即可。(192.168.1.% 该表达式可以匹配所有子网为192.168.1.xxxx的所有ip)
所以如果Host不是localhost,就算密码修改成功之后,也无法在本机进行登录,所以再测试的时候还会报错ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
(3)修改完通过quit退出数据库,将my.cnf文件中新增的代码去掉,然后
service mysql restart
重启数据库,即可正常通过密码登录数据库。
一定一定一定要检查数据库用户的Host字段,因为它直接决定哪些主机可以通过当前数据库用户进行登录!!!!
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- XSS shooting range (3) prompt to win
- ERROR 2003 (HY000) Can't connect to MySQL server on 'localhost3306' (10061)
- Unity教程:URP渲染管线实战教程系列【1】
- Sql解析转换之JSqlParse完整介绍
- Duplicate entry 'XXX' for key 'XXX.PRIMARY' solution.
- Mysql应用安装后找不到my.ini文件
- Minesweeper game (written in c language)
- ABC D - Distinct Trio (Number of k-tuples
- centos7安装mysql5.7步骤(图解版)
- Gaussian distribution and its maximum likelihood estimation
猜你喜欢
![[Cloud Native] DevOps (5): Integrating Harbor](/img/5a/dd33d7d3cb0124f328d2d38fff0125.png)
[Cloud Native] DevOps (5): Integrating Harbor

Tapdata 与 Apache Doris 完成兼容性互认证,共建新一代数据架构

centos7安装mysql5.7

Go language study notes - dealing with timeout problems - Context usage | Go language from scratch

MySQL transaction isolation level, rounding

MySQL transaction (transaction) (this is enough..)

ERP Production Operation Control Kingdee

DVWA installation tutorial (understand what you don't understand · in detail)

Open Source Database Innovation in the Digital Economy Era | 2022 Open Atom Global Open Source Summit Database Sub-Forum Successfully Held

WPF WPF 】 【 the depth resolution of the template
随机推荐
mysql使用on duplicate key update批量更新数据
MySQL transaction (transaction) (this is enough..)
Lua,ILRuntime, HybridCLR(wolong)/huatuo hot update comparative analysis
DVWA之SQL注入
.NET-9.乱七八糟的理论笔记(概念,思想)
sql语句之多表查询
The input input box displays the precision of two decimal places
Lua,ILRuntime, HybridCLR(wolong)/huatuo热更新对比分析
Apache DButils使用注意事项--with modifiers “public“
Go语学习笔记 - 处理超时问题 - Context使用 | 从零开始Go语言
CentOS7 install MySQL graphic detailed tutorial
剑指offer专项突击版第15天
Go language study notes - dealing with timeout problems - Context usage | Go language from scratch
Tapdata 与 Apache Doris 完成兼容性互认证,共建新一代数据架构
Minesweeper game (written in c language)
Pytorch教程Introduction中的神经网络实现示例
MySQL database installation (detailed)
Unity框架设计系列:Unity 如何设计网络框架
[Cloud Native] DevOps (5): Integrating Harbor
DVWA安装教程(懂你的不懂·详细)