Re: mysqldump problem from PHP
| From: | Brad Bonkoski | Date: | Mon, 23 Oct 2006 15:42:40 +0000 |
| Subject: | Re: mysqldump problem from PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-243483@lists.php.net to get a copy of this message | ||
Edward Kay wrote:
#2. Crons run as the user that owns the crontab, not always root. #3. Edward is right, PHP is a wonderful tool, not sure the tool was meant to do the types of things you are trying to do...unless you could fill us in with more details of what the purpose is, then we might be able to give more insight into how. -BNo, cron will typically run as root. You don't need to involve PHP. It looks to me as if you are trying to use web scripting (PHP) to do the sysadmin on your server, for which other methods are more suitable. Edward #1. You can run mysqldump with the same flags a the mysql command line... i.e. -u=<user> --password=<password>cron job. IIf you are trying to automate backups of you database, set up ahi all, Im doing the following dump through PHP: $output = shell_exec('mysqldump '. $db_database .' > '. $backup_path.$filename); It doesnt seem to work but when I run the exact same command (with appropriate values) in the command line it creates the dump file. What could be the reason for this? Thanks in advance. regardsIt appears that it could be because the user that runs the scripts is not allowed to. When I run them on the commandline, I run them as the root user. Is this a common problem? What would the best way be to sort this out keeping in mind security on the server?have a shell script that dumps my databases, zips them and thensends themvia FTP to a remote server. This is automatically run every 12 hours by cron. See http://en.wikipedia.org/wiki/Crontab for more info. Edwardhi Edward, yes I know of CRONtabs but wont this still leave us with the user permission of running mysqldump? because essentially it will still be a PHP file to run the shell command to create the dump file? thanks