我有一个mysql rds实例,当你创建实例时,需要声明一个root用户和密码。
接下来我使用terraform创建了一个新的用户并授予角色。但是我遇到了以下错误:
接下来我使用terraform创建了一个新的用户并授予角色。但是我遇到了以下错误:
Error running SQL (GRANT 'test_role' TO 'test_user'@'%'): Error 1227: Access denied; you need (at least one of) the WITH ADMIN, ROLE_ADMIN, SUPER privilege(s) for this operation
撇开terraform不谈,如果我尝试直接使用mysql为用户分配角色,则会收到相同的错误信息。
CREATE ROLE 'test_role';
GRANT SELECT, EXECUTE ON checkpoint_gg.* TO 'test_role';
CREATE USER 'test_user'@'%' IDENTIFIED BY 'password';
GRANT 'test_role' TO 'test_user'@'%';
显示'root'@'%'的授权信息;
'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE ROLE, DROP ROLE ON *.* TO `root`@`%` WITH GRANT OPTION'
'GRANT APPLICATION_PASSWORD_ADMIN,BACKUP_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,INNODB_REDO_LOG_ARCHIVE,PASSWORDLESS_USER_ADMIN,SHOW_ROUTINE ON *.* TO `root`@`%` WITH GRANT OPTION'
mysql 8
depends_on = [mysql_role.checkpoint_developer]
可能会有所帮助,在其他资源块中相应地添加depends_on
。 - paulgGRANT 'test_role' TO 'test_user'@'%';
也会出现与@paulg相同的错误。 - Kay