Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1058349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:00:51+00:00 2026-05-16T18:00:51+00:00

I have a MySQL DB with a user that has access only a few

  • 0

I have a MySQL DB with a user that has access only a few tables. This user has been granted CREATE TEMPORARY TABLES for this database and by watching the query logs, I can see them create a temporary table and then fail while trying to select from it. Doing GRANT SELECT ON TABLE 'db'.'tmp_tbl' TO 'user'@'localhost'; doesn’t work as the table doesn’t exist at that point.

The user comments on this page suggest a hack to do this but I would have expected there to be a nicer way.


The code that uses this is sorta like this:

CREATE TEMPORARY TABLE t1 SELECT id FROM real1 LIMIT 10;
CREATE TEMPORARY TABLE t2 SELECT id FROM real2 LIMIT 10;

SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t1 JOIN t2 JOIN real3 AS r ON t1.id = r.a AND t2.id = r.b;

In this case, the whole point is that the data (or at least some of it) is live.
I need the results from the first two queries and the values for the join in the third to be the same so using sub queries won’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:00:52+00:00Added an answer on May 16, 2026 at 6:00 pm

    There appears to be work in progress to allow granting more than just “create” permissions for temp tables, but doesn’t appear to be done yet: http://bugs.mysql.com/bug.php?id=27480.

    The workaround mentioned in the man page you linked to would work for you as well. You can join across databases in MySQL, so assuming you did the tmp table trick from the workaround, you could do:

    SELECT tmp.t1.a, tmp.t2.b, realdb.real3.c FROM tmp.t1
           ^^^       ^^^       ^^^^^^
    JOIN tmp.t2 ON  tmp.t1.somefield=tmp.t2.otherfield
         ^^^        ^^^              ^^^
    JOIN realdb.real3 ON tmp.t2.yetanotherifeld = realdb.real3.yetanotherotherfield
         ^^^^^^          ^^^                      ^^^^^^
    etc...
    

    just make sure to specify the databases (as shown by the ^^^ in the sample) in the query and MySQL will happily join away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.