The specified database user/password combination is rejected: [28000][1045] Access denied for user

7 篇文章 0 订阅
4 篇文章 0 订阅

出现这个问题,首先我们先尝试修改密码。不行的话,再尝试给root更多的权限、新建一个用户等等。
一、管理员运行一个命令行窗口
1.停止mysql

net stop mysql

2.跳过输入密码这一步

mysqld --console --skip-grant-tables --shared-memory

二、上面的窗口不动,再重新开一个窗口
1.打开你的mysql的bin文件,我的在D盘。
2.输入如下命令直接进入mysql数据库,注意这个是直接进入软件

mysql

在这里插入图片描述
3.然后输入如下命令

// 显示目前存在的数据库
show databases;
//进入Mysql自动初始化的mysql
use mysql;

在这里插入图片描述
4.查看密码,第一个命令失效因为password改名字了
输入如下命令

select user,authentication_string,host from user;

在这里插入图片描述
5.修改密码

update user set authentication_string='123456' where user='root' and host='localhost';

6.再次查询密码发现root密码已经修改
在这里插入图片描述
7.刷新权限

flush privileges;

三、在Idea里面测试的时候还是不行
让我们回到 Intellij idea,可能点击测试的时候还是会提示The specified database user/password combination is rejected: [28000][1045] Access denied for user ‘root’@‘localhost’ (using password: YES),尝试了很多方法,终于成功了。我们再建一个用户。
1.重复上述的步骤到 “use 数据库名字” 这一步
2.输入下面的命令

create user 用户名@'%' identified by '密码'

3.可能会失败,刷新一下,输入命令flush privileges;
4.再次输入2的命令。
5.重启mysql,到Intellij idea测试一下,输入用户名(上面命令新建的那个),密码。
6.成功!

四、其他错误:报错“ Access denied for user ‘skip-grants user’@‘skip-grants host’ to database ‘information_schema’ ”,那么就授予创建的用户的权限。

grant all privileges on *.* to '创建的用户名'@'%' with grant option;
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值