Tefeles Ionut
Tefeles Ionut

Reputation: 31

mysqldump not working at all :(

I have this code :

function export() 
{
    $exp = system("mysqldump -uguku -pjustbe repadmin > back-up.sql");
    if($exp) {echo 'ok';}
    else { echo 'err';}
}

But it doesn't work, all it does, is to create the "back-up.sql" file, but it's blank. And I get the "err" message.

Upvotes: 0

Views: 1638

Answers (2)

Mei
Mei

Reputation: 1169

Here you have a command that's not running properly. Best thing to do is to capture stderr (where error messages go) and see what the output is. Another thing to note is that environment variables will be different - such as the PATH (refered to by @Joshua_Martell above).

Use this command to capture stderr and see what error messages are being produced:

/usr/bin/mysqldump -uguku -pjustbe repadmin > back-up.sql 2> mysqldump.err

This also uses a full path to mysqldump (use the right path). You also probably should add a path to back-up.sql and, in this case, to mysqldump.err - don't assume that PHP will run in the directory you want as it could change.

Upvotes: 1

Joshua Martell
Joshua Martell

Reputation: 7212

Try using the full path to mysqldump...

$exp = system("/full/path/mysqldump -uroot -p repadmin > back-up.sql");

which mysqldump will tell you what the path should be.

Upvotes: 1

Related Questions