1

I try to save my database in PHP but not work its work only with Shell

With shell (work good)

mysqldump --user=root --password= --host=localhost site > C:\xamppp\htdocs\site\sql\tests.sql

With php (file is created but empty)

system('mysqldump --user=root --password= --host=localhost site > C:\xamppp\htdocs\site\sql\test.sql', $result);

for $result i have 1

I work with XAMP on Windows 7, i test exec and system but its same Thanks you

0

2 Answers 2

2
$return_var = NULL;
$output = NULL;
$command = "mysqldump -u mysql-user -h your_host -pmysql-pass database_name > /directory_path/file.sql";
exec($command, $output, $return_var);

or you can refer to this answer mysqldump via PHP

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks the path with PHP its not correct now its work with C:\xamppp\mysql\bin\mysqldump
1

Use 2>&1

<?php system("mysqldump --user=root --password= --host=localhost site > C:\xamppp\htdocs\site\sql\test.sql 2>&1", $result); ?>

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.