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
andconexao2
.banco2
.tabela2
.id2
?– user12077
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)
.– Zuul
But when I consult two tables with different connections? can’t do
mysql_query("SELECT * FROM fooBar", $conexao1, $conexao2)
... and there?– user12077