|
Posted by jdbartlett on 08/13/07 20:39
On Aug 13, 3:31 pm, rebecca...@gmail.com wrote:
> On Aug 13, 3:29 pm, jdbartlett <cont...@jdbartlett.com> wrote:
>
> > On Aug 13, 3:23 pm, rebecca...@gmail.com wrote:
>
> > > Usually, I log into phpMyAdmin to export the entire SQL DB. Is there
> > > any separate PHP code way to do this without logging in there?
>
> > You could call mysqldump from the command line. If you have a large
> > database to export, you may want to compress it, too. Assuming you
> > use Linux, the command will look something like this:
>
> > mysqldump --compact --compress -uYOURUSERNAME -pYOURPASSWORD
> > DATABASENAME | gzip --best > FILENAME
>
> :)
> So, there is no way via <? php code ?> to sign-in, export?
The easiest method to get a complete backup would be to call mysqldump
using the 'system' command, like so:
<?php
$username = 'YOURUSERNAME';
$password = 'YOURPASSWORD';
$database = 'DATABASENAME';
$filename = 'FILENAME';
system("mysqldump --compact --compress -u{$username} -p{$password}
> {$database} | gzip --best > {$filename}");
?>
Navigation:
[Reply to this message]
|