mysql用其他用户登录报错_mysql登录报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using pa......

在MySQL登录时出现Access denied for user 'root'@'localhost' (using password: YES) 拒绝访问

173f9e31ff009a37d4ac39cd0dbd971c.png

5c0d23b9adbced657b1c287e83d6af20.png

对于出现拒绝访问root用户的解决方案

错误1045(28000):用户'root'@'localhost'(使用密码:YES)拒绝访问

首先解析此英文:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES);

解析的地方有两处:1.Access denied(拒绝访问);2.using password:NO/YES

一、出现access denied的原因有如下可能:

1)mysql的服务器停止:

若MySQL已经没有启动,重启MySQL服务器:systemctl restart mysqld

2)用户的端口号或者IP导致:

若用户的端口号与IP(3306/3307)不一致,打开my.ini文件进行编辑。全部编辑替换为: port=X

3)mysql的配置文件错误----my.ini等文件:

my.ini文件误输入无效内容,不知道到何处。复制替换该文件;有人已经对my.ini文件进行解释以及注释:https://blog.csdn.net/lienfeng6/article/details/78140404

4)root用户的密码错误(后面解决)

二、出现 using password的原因如下:

不输入密码:

c56673bb59141db34337d10978aceb3e.png

错误的密码:

5686de3591f32ca8b36ae7751eb9d3bb.png

解决方案:

vim /etc/my.cnf文件;

在[mysqld]后添加skip-grant-tables(登录时跳过权限检查)

333bfe977d06c2269787f101711cb06c.png

重启MySQL服务:sudo systemctl restart mysqld

aa30bd8892dadb973cdc91bbfe91a9d4.png

修改密码

126c9c8c75437773645d1283a52fcfe7.png

9c39270a928ed3e947cb815d85e23edb.png

登录mysql,输入mysql –uroot –p;直接回车(Enter)

36438326f3e411460301cca5b1d583ce.png

输入:set password for ‘root’@‘localhost’=password(‘Admin123@qwe’);

如果报:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

2f72490143924304b7c4e8be27e33686.png

输入:flush privileges;

b4207638d3c819da2bb651eb85a7a1f5.png

再次输入:set password for ‘root’@‘localhost’=password(‘Admin123@qwe’);

7ba062fc1795b466d72a75633461106b.png

为避免麻烦,再次设置远程访问

38760096fb3115a3bca7d4c7a5fbf311.png

退出:exit

815ba38c02e8cf7a257ec8570a34bc5e.png

再把my.ini的skip-grant-tables删除或者注释掉

36f10481a5e8d69330c3c09a53ad9bb8.png

重启MySQL:sudo systemctl restart mysqld

0f090e189fc2d9a57f32a3da1ea1468e.png

再次连接,成功

cb5dcd0e66de2c982e4c2c2d337933bb.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值