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)]>

ERROR 1045 (28000): Access denied for user 'xxx'@'localhost' (using password: YES)_第1张图片

你可能感兴趣的:(MySQL)