简体   繁体   English

MySQL的:授予用户拒绝命令

[英]mysql: grant command denied for user

I need help regarding mysql grant command. 我需要有关mysql grant命令的帮助。 I need to grant select command on a table to a user which is from different host. 我需要将表上的select命令授予来自不同主机的用户。

GRANT SELECT on db.table TO user@xx.xx.xxx AT password (xx.xx.xxx is ip address of other server and user is username at that server) GRANT SELECT on db.table TO user@xx.xx.xxx AT password (xx.xx.xxx是其他服务器的IP地址,而用户是该服务器上的用户名)

The above statement is giving me error: 上面的声明给了我错误:

1174 - Grant command denied to user 1174-向用户拒绝授予命令

It is working fine in the localhost phpmyadmin. 在localhost phpmyadmin中运行正常。 But when I do it in cpanel phpmyadmin it gives error. 但是,当我在cpanel phpmyadmin中执行此操作时,会出现错误。

Thanks 谢谢

To answer your question, you simply don't have the GRANT OPTION privilege. 要回答您的问题,您根本没有GRANT OPTION特权。

You might have grant privileges in localhost but you certainly don't on your cpanel (live server) 您可能在本地主机中具有授予特权,但您肯定不在cpanel(活动服务器)上

The GRANT statement grants privileges to MySQL user accounts. GRANT语句将特权授予MySQL用户帐户。 To use GRANT, you must. 要使用GRANT,您必须。

  • Have the GRANT OPTION privilege, 拥有GRANT OPTION特权,
  • And you must have the privileges that you are granting. 并且您必须具有所授予的特权。

Also: 也:

The GRANT OPTION privilege enables users to give their privileges to other users. GRANT OPTION特权使用户可以将其特权授予其他用户。 Two users that have different privileges and with the GRANT OPTION privilege are able to combine privileges. 具有不同特权并具有GRANT OPTION特权的两个用户可以组合特权。

As with most hosts, When they create your account, a mysql account/user is also automatically generated to go along with it, and its (usually) given a database privilege . 与大多数主机一样,当他们创建您的帐户时,也会自动生成一个mysql帐户/用户以与其一起使用,并为其(通常)赋予数据库特权 Therefore, the privileges they give you / that comes with your account are all you have. 因此,您所拥有的特权就是他们为您提供的特权。 So if you are the admin of your account and you dont have the grant option privilege, you wont be able to use it. 因此,如果您是帐户的管理员,但没有授予选项特权,则将无法使用它。

Well you don't need the AT password 好吧,您不需要AT password

Here is the example from the MySQL docu: 这是来自MySQL文档的示例:

GRANT SELECT ON db2.invoice TO 'jeffrey'@'localhost';

The password should be handled at your CREATE USER statement. 密码应在CREATE USER语句中处理。

Please try it this way. 请以这种方式尝试。 Does your own user which runs the GRANT -statement has the right to give rights? 您自己的运行GRANT -statement的用户是否有权授予权限? Is it an admin user? 是管理员用户吗?

Try This 尝试这个
Add skip-grant-tables in my.cnf file under the [mysqld] section or otherwise stop mysqld and start it with the --skip-grant-tables option. 在[mysqld]部分下的my.cnf文件中添加skip-grant-tables,否则停止mysqld并使用--skip-grant-tables选项启动它。

Use mysql to connect to DB without password without -p

Then execute this:

UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
FLUSH PRIVILEGES;

Then execute: GRANT ALL ON *.* TO 'root'@'localhost';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM