mysql - 错误 1044 (42000) : Access denied for user '' @'localhost' to database 'db'

标签 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

最佳答案

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

关于mysql - 错误 1044 (42000) : Access denied for user '' @'localhost' to database 'db' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8838777/

相关文章:

MySQL SELECT * 和百分比

mysql - 选择ID后的记录

mysql - 最喜欢的照片

php - 如何处理无限重复的日期

php - 在一定时间间隔后从表中删除数据。比方说(60 分钟)

javascript - 无法安装 Node 模块,因为 'This is related to npm not being able to find a file.'

javascript - 如何设置 jquery onclick 函数以仅针对可编辑表中的特定表列或类?

mysql - mysql表中的随机记录

php - 确定帖子属于哪个页面

mysql - 具有二进制信息的多行多列DB表的设计