0

Using MySQL, how can I assign permissions to a user so they can create and manipulate temporary tables, but not alter any of the data in permanent tables?

Alternatively, is there a way for a user with CREATE TEMPORARY TABLES to create a temporary table such that they have full rights for that table?

1 Answer 1

1

I understand this doesn't exactly answer your request but...

You may want to handle it using an ACL (Access Control List) of permissions for this user. You want to specify by table what this user can SELECT. Next, create a database specifically for this user's purpose with SELECT,CREATE permissions.

E.g.

GRANT SELECT ON dbname.tablename1 TO 'username'@'ip-or-hostname' IDENIFIED BY 'password';
GRANT SELECT ON dbname.tablename2 TO 'username'@'ip-or-hostname' IDENIFIED BY 'password';
GRANT SELECT ON dbname.tablename3 TO 'username'@'ip-or-hostname' IDENIFIED BY 'password';

GRANT CREATE,SELECT,DROP ON tmpdb.tablename1 TO 'username'@'ip-or-hostname' IDENIFIED BY 'password';
GRANT CREATE,SELECT,DROP ON tmpdb.tablename2 TO 'username'@'ip-or-hostname' IDENIFIED BY 'password';
GRANT CREATE,SELECT,DROP ON tmpdb.tablename3 TO 'username'@'ip-or-hostname' IDENIFIED BY 'password';
3
  • Will that work for temporary tables, or only for normal tables?
    – DrStalker
    Dec 17, 2009 at 6:54
  • Only for normal tables, which is why I started my answer the way that I did. However you can create tables with the ENGINE=MEMORY and you basically have temp tables.
    – randomx
    Dec 22, 2009 at 23:09
  • It's close enough for this case, since I know the temporary table will only be used by one DB connection at a time.
    – DrStalker
    Jan 5, 2010 at 7:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .