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:

  1. all queries executed through singleton class, opens connection , keeps opened whole session (as far understand code)

  2. every time mysql_query returns false, exception thrown.

  3. 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.

  4. some queries returning 1045 error: access denied user 'appuser'@'localhost' (using password: yes)

here comes "weird" behavior:

  1. 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).

  2. 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.

  3. the stack trace of thrown exceptions (in php, obviously) shows exceptions came singleton class handle queries.

  4. there seems no pattern in "rejected" queries. big select queries, nothing more. have left outer joins, others have 24 from clauses.

  5. 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 selects, 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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -