ERROR 1045 (28000): Access denied for user 'xxx'@'localhost' (using password: YES)

ERROR 1045 (28000): Access denied for user ‘xxx’@‘localhost’ (using password: YES)

在MariDB添加新用户时:

mysql> GRANT ALL PRIVILEGES ON wds. TO wds@’%’ identified by ‘wds0k’;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> FLUSH PRIVILEGES;
*

没有问题, 但一旦退出root用户重新登陆的时候, 会出现错误:
ERROR 1045 (28000): Access denied for user ‘wds’@‘localhost’ (using password: YES)

网上很多答案都不靠谱, 最终发现有位同学的答案可以解决:
https://www.cnblogs.com/summertime-wu/p/7466160.html
但如果直接按照他的方法会有些问题:

MariaDB [(none)]> Delete FROM user Where User=’’ and Host=‘localhost’;
ERROR 1046 (3D000): No database selected

这时候需要先选择mysql数据库, 然后按照操作执行:

MariaDB [(none)]> 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
MariaDB [mysql]> Delete FROM user Where User=’’ and Host=‘localhost’;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> exit;
Bye
[root@2 node-v10.13.0-linux-x64]# mysql -uwds -p’wds0k’
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 5.5.60-MariaDB MariaDB Server
Copyright © 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
MariaDB [(none)]>

在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值