I keep getting empty files generated from running
$command = 'mysqldump --opt -h localhost -u username -p \'password\' dbname > \'backup 2009-04-15 09-57-13.sql\'';
command($command);
Anyone know what might be causing this? My password has strange characters in it, but works fine with connecting to the db.
I've ran exec($command, $return)
and outputted the $return array and it is finding the command. I've also ran it with mysqldump > file.sql
and the file contains
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
So it would seem like the command is working.
It dumps one or more MySQL databases for backup or transfer to another SQL server. The mysqldump command can also generate output in CSV, other delimited text, or XML format.
db_backup. sql is automatically generated by the mysqldump command, and is located in the current directory ( . ) by default. If you need to specify a directory, you can directly specify /path/to/target/db_backup.
If mysqldump is not identified by the cmd prompt that means it cannot recognize where the mysqldump.exe is located. You need to add path of the directory where the exe is located in the PATH variable under environment variables. After doing that your command will start working in the cmd prompt.
Remove the space between -p
and the password. If it didn't work, try to remove the quotes from the password
from MySQL documentation:
If you use the short option form (-p), you cannot have a space between the option and the password.
however, it is fine to have space with -h
and -u
options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With