当前位置: 首页 >数据库 > ERROR 1045 (28000): Access denied for user 'xxx'@'localhost' (using password: YES) (转)

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

踩坑2小时 ,终于搜到解决办法

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 waing (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 tu 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)]>
在这里插入图片描述

作者:未来全栈攻城狮
来源链接:https://www.cnblogs.com/niucunguo/p/14264700.html

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaclub.cn/database/118369.html

分享给朋友:

“ERROR 1045 (28000): Access denied for user 'xxx'@'localhost' (using password: YES) (转)” 的相关文章

全面解析Redis 2022年05月13日 10:22:02
MYSQL的存储过程 2022年05月16日 21:54:19
Linux安装MySQL(超详细) 2022年05月16日 21:54:54
mysql查询字段为null 返回0 2022年06月10日 20:48:10
关于mysql数据库连接异常处理 2022年06月12日 19:21:20
MySQL查询请求执行过程分析 2022年06月15日 10:06:22
mysql 近几天内 2022年06月15日 15:07:52
Mysql拼接查询结果 2022年06月15日 19:36:23