D. Rattansingh
D. Rattansingh

Reputation: 1669

Generating a dump file from PHP

I'm trying to generate a mysql dump file from PHP using the following:

exec('mysqldump -u root -ppassword maindb > c:\DB_Dump.sql');

However the file being generated is blank. Anyone knows what's wrong?

From the cmd, this is working: cd C:\Program Files\MySQL\MySQL Server 5.5\bin to change the path and then

mysqldump -u root -ppassword maindb > c:\DB_Dump.sql

But I'm trying to do it within PHP.

Upvotes: 0

Views: 278

Answers (1)

Álvaro González
Álvaro González

Reputation: 146660

To discard most common issues:

  • Use full paths
  • Send output to a publicly writable directory

The path to mysqldump in your computer appears to have white spaces. Make sure you quote it properly:

exec('"C:\\Program Files\\MySQL\\MySQL Server 5.5\\bin\\mysqldump" -u root -ppassword maindb > c:\\DB_Dump.sql 2> c:\file.err.txt')

Upvotes: 2

Related Questions