Question

I am trying to access information from multiple databases with one user account. Even though I am fairly sure the user has rights to both databases, MySQL is rejecting my SELECT query on the second database.

My SQL query looks like this:

SELECT a.id AS id, a.name AS a_name, b.naam AS b_name
FROM accounts a
LEFT JOIN database_b.uac_bridge bridge ON a.id = bridge.foreign_id
LEFT JOIN database_b.leden b ON b.id = bridge.master_id
WHERE a.active=1

I have removed some names from the code and transliterated it from CodeIgniter ActiveRecord so I hope there are no typo's in the query. I am fairly sure the query itself is correct, it runs fine on my development machine (Windows 7, MySQL 5.5.14) but fails on the server (not sure what OS, some Linux variant, MySQL 5.5.27).

I get the following error message:

Error Number: 1142
SELECT command denied to user 'username'@'localhost' for table 'uac_bridge'

The user that is logged in is created for database_a and has a SELECT grant (but no others) on database_b (configured through DirectAdmin). I have confirmed that the user can read data in database_b by logging in to phpMyAdmin.

Does anyone know how this can be fixed?

Était-ce utile?

La solution

For reference, the answer is simple, MySQL database names are case-sensitive on Linux but not on Windows (https://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html).

This was the error, I was not referring to the database in the right capitalization and MySQL gives a no-permission error because it does not recognize the database name.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top