对具有GRANT ALL PRIVILEGES的用户拒绝CREATE命令

[英]CREATE command denied for user that has GRANT ALL PRIVILEGES


I am trying to set up a MySQL replication slave, and am having a very difficult time running LOAD DATA FROM MASTER;. Yes, I know it is deprecated, but I am running MySQL 5.1, and that isn't my problem at the moment.

我正在尝试建立一个MySQL复制从站,并且我很难从MASTER运行LOAD DATA;是的,我知道它已被弃用,但我正在运行MySQL 5.1,这不是我目前的问题。

For some reason MySQL keeps telling me the CREATE command is denied, but a check of SHOW GRANTS says otherwise. Check this out:

出于某种原因,MySQL一直告诉我CREATE命令被拒绝,但是SHOW GRANTS的检查说不然。看一下这个:

mysql> SHOW GRANTS;
+--------------------------------------------------------------------------------------------------------------------+
| Grants for replicator@%                                                                                            |
+--------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'replicator'@'%' IDENTIFIED BY PASSWORD '*ABCDEFABCDEFABCDEFABCDEFBLAHBLAHBLAHBLAH' |
+--------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> LOAD DATA FROM MASTER;
ERROR 1142 (42000): CREATE command denied to user 'replicator'@'localhost' for table 'aggregate'
mysql>

What I thought was odd here is that when calling LOAD DATA FROM MASTER, it thinks I am 'replicator'@'localhost', yet SHOW GRANTS says 'replicator'@'%'. Just to be safe, I gave the same privs to 'replicator'@'localhost' as well.

我认为奇怪的是,当调用LOAD DATA FROM MASTER时,它认为我是'复制者'@'localhost',但SHOW GRANTS说'复制者'@'%'。为了安全起见,我也向'replicator'@'localhost'提供了相同的权限。

mysql> SHOW GRANTS FOR 'replicator'@'localhost';
+----------------------------------------------------------------------------------------------------------------------------+
| Grants for replicator@localhost                                                                                            |
+----------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'replicator'@'localhost' IDENTIFIED BY PASSWORD '*ABCDEFABCDEFABCDEFABCDEFBLAHBLAHBLAHBLAH' |
+----------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

So, any thoughts on why this is all messed up? Yes, I did FLUSH PRIVILEGES many times as well.

那么,为什么这一切都搞砸了?是的,我也做了很多次FLUSH PRIVILEGES。

Thanks in advance for any advice you can give.

提前感谢您提出的任何建议。

4 个解决方案

#1


14  

I would like to suggest the following:

我想建议以下内容:

When you login next time run this query:

当您下次登录时运行此查询:

SELECT USER(),CURRENT_USER();

If you see two different usernames, you have a weird scenario

如果您看到两个不同的用户名,则会出现奇怪的情况

This you can find in the MySQL 5.0 Certification Study Guide (ISBN 0-672-32812-7), Chapter 34 or 35

您可以在MySQL 5.0认证学习指南(ISBN 0-672-32812-7),第34章或第35章中找到它

USER() echoes what you attempted to login as

USER()回应您尝试登录的内容

CURRENT_USER() echos what mysql ALLOWED YOU to login as.

CURRENT_USER()回显了mysql允许你登录的内容。

Try connecting using as replicator using 127.0.0.1 and run the same query.

尝试使用127.0.0.1作为复制器进行连接并运行相同的查询。

You may also want to maker sure all necessary columns are present in mysql.user for the version of mysql you are using. If you did not upgrade the mysql.user table (from a migration from MySQL 4 - MySQL 5, or MySQL 5.0 to 5.1) columns in mysql.user could be out of sync.

您可能还希望确保mysql.user中存在所有必需的列,以用于您正在使用的mysql版本。如果你没有升级mysql.user表(从MySQL 4的迁移 - MySQL 5,或MySQL 5.0到5.1),mysql.user中的列可能不同步。

#2


15  

For future searchers, I found that I get this error when using a combination of MySQL Workbench and phpMyAdmin: if you 'copy SQL' from the tables list, it prepends the schema name on to the table names in the create statement (and in the foreign key commands that may be part of it).

对于未来的搜索者,我发现在使用MySQL Workbench和phpMyAdmin的组合时出现了这个错误:如果你从表列表中复制SQL,它会将模式名称添加到create语句中的表名(并且在可能是其中一部分的外键命令)。

Carefully removing the schema name cured this issue for me.

小心删除模式名称为我解决了这个问题。

For example:

例如:

CREATE  TABLE IF NOT EXISTS `schema`.`table1` (
...blah blah blah...

CONSTRAINT `fk_user_id`
    FOREIGN KEY (`user_id` )
    REFERENCES `schema`.`table1` (`id` )
...blah blah blah...

should be changed to:

应改为:

CREATE  TABLE IF NOT EXISTS `table1` (
...blah blah blah...

CONSTRAINT `fk_user_id`
    FOREIGN KEY (`user_id` )
    REFERENCES `table1` (`id` )
...blah blah blah...

#3


5  

Oddly enough, simply QUIT-ing the client and reconnecting resolved the issue! Evidently, FLUSH PRIVILEGES is not enough.

奇怪的是,只需退出客户端并重新连接即可解决问题!显然,FLUSH PRIVILEGES是不够的。

I'd like to hear any comments if you have them on why that is. I have always heard that FLUSH PRIVILEGES will do just that. Could it have something to do with me originally logging in as 'replicator'@'%' and then later creating the 'replicator'@'localhost' account?

如果您了解其中的原因,我想听听您的意见。我一直听说FLUSH PRIVILEGES就是这么做的。它可能与我最初以'replicator'@'%'登录然后创建'replicator'@'localhost'帐户有关吗?

In any case, if you have weird permissions issues like this, I guess it is worth trying to reconnect the client.

在任何情况下,如果你有像这样的奇怪的权限问题,我想值得尝试重新连接客户端。

#4


0  

When using MySQL Workbench Migration Wizard to copy a DB from one server to another, I was presented with the same error message because the new DB name did not match the original one. The new server automatically places its domain name in front of all DB names creating a mismatch in names. Therefore when transferring DB xyz to the new server domain, it called the new DB domain_xyz and the above error message occurred for every table creation.

当使用MySQL Workbench Migration Wizard将数据库从一个服务器复制到另一个服务器时,我收到了相同的错误消息,因为新的数据库名称与原始数据库名称不匹配。新服务器自动将其域名放在所有数据库名称的前面,从而导致名称不匹配。因此,在将DB xyz传输到新服务器域时,它会调用新的DB domain_xyz,并且每次创建表时都会出现上述错误消息。

To fix the problem, I manually edited the new DB name after the migration schema was generated, changing it from xyz to doman_xyz.

为了解决这个问题,我在生成迁移模式后手动编辑了新的数据库名称,将其从xyz更改为doman_xyz。

Tip-of-the-hat to Camwyn's response that got me looking in this direction.

对Camwyn的回应提示,让我朝这个方向看。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2011/03/10/758a929e38ebb645b6de9dceb4c35d5.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号