-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!

1
  • 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 Commented Feb 27, 2017 at 16:49

2 Answers 2

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);
Sign up to request clarification or add additional context in comments.

Comments

-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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.