【发布时间】:2012-02-08 23:02:51
【问题描述】:
我想开始在 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
【问题讨论】:
-
您需要以具有权限的用户身份登录。安装 MySQL 时至少应该创建
root。 -
在安装过程中它告诉我设置密码,我现在将它设置为 root 我该怎么办?
-
您需要以 root 身份登录——例如,通过运行
mysql -u root -p。然后您将拥有数据库服务器的完全权限,并且您可以创建其他用户。 -
使用命令行登录时,以root身份登录:mysql -u root -p
-
@nikparsa:不,你应该运行它而不是 'mysql'——从 shell 提示符,而不是 mysql 提示符。
标签: mysql