Hello All..
My setup: Ubuntu LAMP, application built w/ zend framework
My Problem: I have a few php scripts that I trigger via cron - daily email reports, rrd data capture etc.. I launch them via a cronjob like 'php -f scriptname.php'.
When I test the scripts from the commandline, logged in as myself, everything works fine. However, when the same script executes as root (via cron OR sudo) it fails with the following errors.
Warning: Access denied for user 'root'@'localhost'
Warning: mysql_real_escape_string
(): A link to the server could not be established ...
I've done some research and I'm fairly sure that Im establishing a connection to mysql ahead of time, although the process is a bit obfuscated because Im working with the zend framework- Bootstrap class calls zend_db which calls registry class for the db credentials. and so on.
I've discovered one workaround: 'sudo -u myusername php -f scriptname.php' but I'd really like to know what Im doing wrong here..
TIA!