Reputation: 1323
I want to take daily backup of my DB for that I use following code
$username =escapeshellcmd($dbuser);
$password =escapeshellcmd($dbpwd);
$hostname =escapeshellcmd($server);
$database =escapeshellcmd($dbname);
$backupFile='/mypath/dbBackup/'.date("Y-m-d-H-i-s").'.sql';
$command = "mysqldump -u$username -p$password -h$hostname $database > $backupFile";
system($command, $result);
I place this code in php file and call that file through cron job that I set to take daily DB backup. This works fine but problem is my column in table contains content that have number of single and double quotes. Because of this when backup file is created (.SQL file) it contains broken INSERT query like this
INSERT INTO `mytable` VALUES (1,'don\'t read this article','test\'ssdf','',1,5,6,0),(2,'goal setting tips you\'d want to try','Category- ' ....
So is there any way to escape these single and double quotes in .SQL backup file while using mysqldump.
Upvotes: 0
Views: 2763
Reputation: 157839
You don't have to escape anything in the MySQL backup file.
Upvotes: 1