Nytram
Nytram

Reputation: 343

how to use mysqldump command in php?

I want to backup my database. So I've used this command

$command = "mysqldump --user=root asset_management > D:\assetmanagement\public\backup\backup.sql"; system($command);

But this will produce an empty sql file.. can anyone help?

Upvotes: 1

Views: 1502

Answers (2)

$command = "mysqldump --user=root -pass=yourpassword asset_management > D:\assetmanagement\public\backup\backup.sql"; system($command);

Upvotes: 1

pravinjakate1
pravinjakate1

Reputation: 11

Suppose your mysqldump is in the C:/wamp/bin/mysql/mysql5.1.33/bin/ folder

$mysqlPath="C:/wamp/bin/mysql/mysql5.1.33/bin/";
//There should be password for root user. Blank password will not work.

$command = $mysqlPath . "mysqldump.exe asset_management > D:\assetmanagement\public\backup\backup.sql --user=root --password=yourpassword ";

Upvotes: 1

Related Questions