1

わかりました、私は当惑しています。更新しようとすると「アクセスが拒否されました」というエラーが表示されます。そのユーザーがそのテーブルで更新を実行できるようにする許可がありますが、とにかく拒否されています。はい、「プロパティのフラッシュ」を試しました。

$ mysql -h DBHOST -u DBUSER -p DBNAME
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7340
Server version: 5.0.77 Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> update user set lastlogin = now() where userid = 1;
ERROR 1227 (42000): Access denied; you need the SUPER privilege for this operation
mysql> show grants for DBUSER;
+--------------------------------------------------------------------------------------+
| Grants for DBUSER@%                                                                  |
+--------------------------------------------------------------------------------------+
...
| GRANT SELECT, INSERT ON `DBNAME`.`useroldpassword` TO 'DBUSER'@'%'                     |
...
| GRANT SELECT, INSERT, UPDATE ON `DBNAME`.`user` TO 'DBUSER'@'%'                      |
...
+--------------------------------------------------------------------------------------+
68 rows in set (0.01 sec)

mysql>

テーブルにトリガーがあります。

CREATE TRIGGER DEFINER=`DEFINER`@`localhost` UserPasswordUpdate BEFORE UPDATE ON User
FOR EACH ROW
BEGIN
    DECLARE count int;
    IF(NOT NEW.Password<=>OLD.Password) THEN
        SELECT count(*) into count FROM UserOldPassword WHERE UserID=NEW.UserID AND Password=NEW.Password;
        IF(count != 0) THEN
             INSERT INTO Unknown VALUES(1);
        END IF;
        INSERT INTO UserOldPassword(UserID,PasswordDate,Password) VALUES(NEW.UserID, NOW(), NEW.Password);
        SET NEW.LastPasswordChangeDate=NOW();
    END IF;
END

実行ユーザー (上記を参照) と指定された定義者の両方が、UserOldPassword テーブルに挿入する権限を持っている必要があります。

mysql> show grants for DEFINER;
+---------------------------------------------------------------------------------+
| Grants for DEFINER@%                                                            |
+---------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'DEFINER'@'%' IDENTIFIED BY PASSWORD '...'                |
| GRANT ALL PRIVILEGES ON `DBNAME`.* TO 'DEFINER'@'%'                             |
+---------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> show grants for DEFINER@localhost;
+-----------------------------------------------------------------------------------------+
| Grants for DEFINER@localhost                                                            |
+-----------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'DEFINER'@'localhost' IDENTIFIED BY PASSWORD '...'                |
| GRANT ALL PRIVILEGES ON `DBNAME`.* TO 'DEFINER'@'localhost'                             |
+-----------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
4

3 に答える 3

2

試す:

GRANT SUPER ON `DBNAME`.`user` TO 'DBUSER'@'%'

おそらくテーブルにトリガーがあるため、機能していません。

于 2011-09-12T16:32:11.463 に答える
1

MySQL 5.0.77 から 5.5.15 にアップグレードしたところ、正常に動作するようになりました。

于 2011-09-12T18:05:10.967 に答える
0

これを実行します:

mysql> flush privileges;
于 2011-09-12T16:19:11.403 に答える