-2

Good evening, I am currently working on a mysql backup system but I can't get it to run.

My current code:

exec ("C:\xampp\mysql\bin\mysqldump.exe --routines -h $db_server -u $db_user -p $db_pass --single-transaction $db_name > C:\xampp\htdocs\test.sql");

I read the documentation on mysqldump and tried several ways, for example the above and also:

exec ("mysqldump --routines -h $db_server -u $db_user -p $db_pass --single-transaction $db_name > C:\xampp\htdocs\test.sql");

What am I doing wrong? Thanks in advance!

Reun
  • 5
  • 3
  • 1) You are injecting raw input into shell 2) You aren't making any attempt to find out if the command executes successfully or to retrieve error messages if any – Álvaro González Feb 27 '17 at 16:49

2 Answers2

0

I don't know what you mean by cannot run. It is it dump empty file or nothing at all happen. So I will write regarding on what I have understood. I also encounter same issues years back. Read here.

$filename = test.sql   

$command = sprintf("C:\xampp\mysql\bin\mysqldump.exe --opt -h%s -u%s -p%s %s > C:\xampp\htdocs\%s",

$db_server,
$db_user,
$db_pass,
$db_name,
$filename
);
system($command);
Community
  • 1
  • 1
Salehin Rafi
  • 351
  • 2
  • 6
  • 16
-1

try this script http://www.lecoindunet.com/sauvegarder-bdd-mysql-mysqldump-php-27

or this

Using a .php file to generate a MySQL dump

Community
  • 1
  • 1
mohamed jebri
  • 261
  • 3
  • 13