ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)已解决

目录

1、背景 

2、解决方法

1、背景 

        MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的关系数据库管理系统应用软件。

        在日常的使用MySQL的过程中,有时候登录正确的密码后还是报下面这个错误(rpm 安装的MySQL 5.7)

[root@hadoop105 ~]# mysql -uroot -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

2、解决方法

1.配置无密码

        vim /etc/my.cnf

        在[mysqld]里配置跳过密码进行登陆

skip-grant-tables

 2.重启MySQL数据库

service mysqld restart
mysql -uroot -p  #不输入密码直接回车进入MySQL

         重新赋密码并且授权账户远程登录权限

use mysql;

select user,host from user; 
update mysql.user set authentication_string=password('123456') where User="root" ;  
flush privileges;  #刷新系统授权表

grant all privileges on *.* to root@'%'; #授权root账户远程访问权限  
flush privileges;   #刷新系统授权表 

3.再次修改my.cnf,注释掉my.cnf,重启MySQL,输入更改后的密码即可

vim /etc/my.cnf

#skip-grant-tables

service mysqld restart

mysql -uroot -p

         有用点赞收藏吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陆尼

5以上的鼓将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值