ahm i'm used this
$dump = "mysqldump-u$user-p$pass$dbname>db/backup.sql";
system($dump);
but when i open the backup.sql, its blank
Mysql Dump - Database Backup
Moderator: General Moderators
Re: Mysql Dump - Database Backup
You did put spaces in there, right?
Try running that on the command line yourself and see if there are any error messages.
Try running that on the command line yourself and see if there are any error messages.
-
venkatgants
- Forum Newbie
- Posts: 3
- Joined: Thu Jun 03, 2010 1:21 am
Re: Mysql Dump - Database Backup
Code: Select all
$backupFile = "db/".date("Y-m-d-H-i-s")."."."sql";
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "pdmr_tracky";
echo $dump = "mysqldump --opt -h ".$dbhost." -u ". $dbuser." -p ". $dbpass. $dbname." > ".$backupFile;
system($dump);This is code. How to use in command prompt.
d:wamp this is wamp path...
pls help me...
Last edited by Benjamin on Thu Jun 03, 2010 2:23 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
Reason: Added [syntax=php] tags.
Re: Mysql Dump - Database Backup
Like I said, try running that from the command line and see what happens.
-
venkatgants
- Forum Newbie
- Posts: 3
- Joined: Thu Jun 03, 2010 1:21 am
Re: Mysql Dump - Database Backup
our wamp path is D:\wamp, we dont know how to enter query and where (path).
so that we included php code. please guide me.
so that we included php code. please guide me.
Re: Mysql Dump - Database Backup
TRy this code
Create a folder named "backup" in current folder where this program runs and chmod to 777
this will
Create a folder named "backup" in current folder where this program runs and chmod to 777
Code: Select all
<?php
/*
* -------------------------------------------------------------
Database backup script
* -------------------------------------------------------------
*/
set_time_limit(0);
/*
* Directory name for storage
* All back will store to backup folder in the current running folder
*/
$dirName = dirname(__FILE__)."";
/*
* Database configuration
*/
$dbUser = "nroot";
$dbPass = "pass";
$dbName = "dbname";
$dbHost = "localhost";
/*
* Executes the Mysqldump for backup
*/
$fileName = strtotime(date("Y-m-d H:i:s"))."-{$dbName}-backup.sql";
$command = "mysqldump --opt --host={$dbHost} --user={$dbUser} --password={$dbPass} {$dbName} > {$dirName}/backup/{$fileName}";
$res = exec($command);
echo $command;
echo $res;
?>
Last edited by Benjamin on Mon Jul 12, 2010 5:57 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
Reason: Added [syntax=php] tags.