SELECT command denied to user

Asked

Viewed 1,196 times

2

Error: SELECT command denied to user 'banco'@'xxx.xx.xx.xx' for table 'table'

This error only happens in my hosting, is running site perfectly, I am consulting 2 databases in a single query using:

 `banco`.`table` ... 

Is it user permissions? If so, how can I release permission, remembering that it is hosting?

1 answer

6


This error is generated when you are trying to access a database with a user who does not have permissions on it.

For your particular case, the user you are trying to access has no permissions to execute the SELECT in that database.

Confirms if the user exists and has permissions to access the database, if not, you should create a user and associate it with the database in question.

The way to create the user and associate it to the database will depend on your hosting, but you certainly have access to a cPanel admin panel where you can access to create mail accounts, databases and their users.


In exceptional cases, it has been reported on the SOEN that in consultations that work with two or more tables and:

  • one of them does not exist;
  • or there is an error in SELECT where the table name is misspelled

Mysql instead of giving the indication that the table does not exist, displays the user’s missing permissions error message regarding the SELECT running.

Also confirm that the tables exist in the database of your accommodation.

  • Hello, your answer is correct, checking all my data and script I realize that really the user does not have permission, however the tables exist according to the script. In my hosting, each database has a different user, what I perform in my script is to connect to the two databases with the different users, but in Query it uses only one user to access the two databases. It would have to do for the query to search for example conexao1.banco1.tabela1.id1 and conexao2.banco2.tabela2.id2?

  • 1

    He’s using the same access credentials probably because when you make the queries you’re not searching using the right connection. You have to establish a link for each database given users are different, save each link in a variable and query the correct variable: $conexao1 = mysql_connect('host', 'user', 'pass'); and for the second $conexao2 = mysql_connect('host', 'user', 'pass') consulting for the bank 1 $resultados = mysql_query("SELECT * FROM fooBar", $conexao1).

  • But when I consult two tables with different connections? can’t do mysql_query("SELECT * FROM fooBar", $conexao1, $conexao2)... and there?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.