2006-02-16, 08:39 AM
I am at the moment building a PHP/MySQL-powered CMS, and recently I have had some trouble when moving the latest versions of the source code to other servers. What seemed to be happening was an error 'No database selected' despite the fact that I always used mysql_select_db() before any database queries. So I did some diagnostics into the problem and I've discovered that MySQL is actually denying access to the database. So on my home system, I tried to recreate the problem (running MySQL as root):
Code:
mysql> revoke all privileges on pkbeta.* from pkbetauser@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> grant usage on pkbeta.* to pkbetauser@localhost identified by "xxxxxxx";
Query OK, 0 rows affected (0.00 sec)
On my home system, MySQL is now denying privileges to select the database. :( But if I revoke usage this happens:
Code:
mysql> revoke all privileges on pkbeta.* from pkbetauser@localhost;
ERROR 1141 (42000): There is no such grant defined for user 'pkbetauser' on host 'localhost'
Which means the usage privileges were never granted. :(
Adding privilieges by name (e.g. select, insert, update...) works. So why is it not granting usage privilieges on my home system, but most importantly why can't I connect to a database on a different server? Eventually this will not be hosted on a machine I have direct control over (no SSH access or anything), so this is a big issue. :(
Any help would be great, thanks. :)