php - (Apparently) weird "Access denied" MySQL error -
i begun working on legacy php application , found myself fighting strange behavior. i'll try explain scenario/code/error:
all queries executed through singleton class, opens connection , keeps opened whole session (as far understand code)
every time
mysql_query
returnsfalse
, exception thrown.many queries executes "fine", complaining not existing tables (one of tasks clean messy-clipper-inherited-database-scheme, i'm running code , creating tables needed). after creating missing tables, queries runs well.
some queries returning
1045
error:access denied user 'appuser'@'localhost' (using password: yes)
here comes "weird" behavior:
i have enabled general log in mysql install, there no mentions of access denied errors. application queries seem run fine (i "seem to" because i'm having problems understanding sections of log format).
the username/password configured in singleton class ok. can log in using mysql cli interface, besides many other queries runs fine. if try use wrong username/password on mysql cli, access denied correctly logged in general log.
the stack trace of thrown exceptions (in php, obviously) shows exceptions came singleton class handle queries.
there seems no pattern in "rejected" queries. big
select
queries, nothing more. haveleft outer
joins, others have 24from
clauses.i'm logging
mysql_stat
result, on every query, , prints server status before both working queries , failing ones. although, i'm not sure if function depends on valid credential/session mysql server.
so, guys think going on down here? clue? educated guess?
if need more information/background, i'll happily provide... :)
examining in more details problematic select
s, find common table, between them. guess what? not table
, view
, actually. when tried select
view
, using graphic tool (mysql workbench), error clear , "obvious".
when developer exported database (mysql dump), tool added line this, on every view
creation code:
/*!50013 definer=`oldappuser`@`%` sql security definer */
i don't know why, did. since local database has different username/password/scheme, became source of 4-hours-long-headache.
to fix dropped old view
, re-created it, without definer
directive.
moral of story: watch out options check when dumping database , pay attention security
stuff, in case changing user/pass/scheme in new server.
Comments
Post a Comment