Click to See Complete Forum and Search --> : MySQL - 'No Database Selected'


scaiferw
03-07-2006, 10:27 PM
I'm getting this error through mysql_error() on connect. I finally figured out - I think - the old password/new password thing, and got past that error message to this one.

My connect code is this:
$dbh=mysql_connect ("localhost", "db_admin_acct", "password");
mysql_select_db ("rot7040_main");

I know the account name is good (that's the one I fixed to get rid of the first error) and I know the db name is good and the db is there.

Can someone tell me where I've gone wrong?

scaiferw
03-07-2006, 10:49 PM
Found it, though the error message was no help.

I looked at the Schema privileges for the account in MySQL Administrator and realized it didn't have any permissions for that database. I enabled all permissions (will fine tune that later) and I at last have everything working.

So the problem wasn't that the db wasn't selected - it was - but that the account didn't have proper permissions to access the db.

NogDog
03-07-2006, 10:56 PM
Or, the error message was accurate, if not very enlightening: the database was not selected because the user did not have permission to select it. :)