user225269
user225269

Reputation: 10893

mysql dump generating a blank sql file

Please help, I got this code from googling on how to use mysql dump on php. But its just generating a blank .sql file. I already tried putting the mysqldump.exe on the same directory as the php file but doesn't work.

<?php
system('mysqldump -uroot -pmypassword test > C:\wamp\www\test\test.sql');
?>

I'm trying to do this, but I am running windows 7 and I get access denied error if I change the privileges in cmd.exe even if I'm the admin.

Please help, why is it generating a blank sql file? How do I solve this?

Upvotes: 0

Views: 2184

Answers (2)

Aaron W.
Aaron W.

Reputation: 9299

Try putting a space between the -u and your username

<?php
system('mysqldump -u root -pmypassword test > C:\wamp\www\test\test.sql');
?>

Upvotes: 2

Guillaume Lebourgeois
Guillaume Lebourgeois

Reputation: 3873

You should check the return value from the "system" operation. You should check your file path. You should check the database exists.

A good way to verify all that is to execute this command by hand, before using it in php.

Upvotes: 1

Related Questions