微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

错误 1044 (42000): 拒绝用户 ''@'localhost' 访问数据库 'db'

如何解决错误 1044 (42000): 拒绝用户 ''@'localhost' 访问数据库 'db'

不,您应该MysqL -u root -p在 bash 中运行,而不是在 MysqL 命令行中运行。如果您在 MysqL 中,则可以通过键入 。

解决方法

我想开始在 MySQL 中编写查询。

show grants显示:

+--------------------------------------+
| Grants for @localhost                |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |
+--------------------------------------+

我没有任何用户 ID,但是当我想创建一个用户时,我没有权限,即使我没有一个用户,我也不知道如何创建权限!

mysql> CREATE USER 'parsa'@'localhost' IDENTIFIED BY 'parsa';
ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER pr
ivilege(s) for this operation

我尝试以 root 身份登录:

mysql> mysql -u root -p;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'mysql
 -u root -p' at line 1
mysql> mysql -u root -p root;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'mysql
 -u root -p root' at line 1

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。