I use MySQL Dump for nightly backups. The time has come to stop the unsafe practice of using password on the command line. Here is what I have that works:
exec('mysqldump -uuser -ppass '.$database.' > '.$filepath.');
Now using mysql_config_editor I've set a login path:
mysql_config_editor set --login-path=name --host=localhost -user=uname --password
And the following works when executing manually by mysql direct on the command line:
mysqldump --login-path=name '.$database.' > '.$filepath
But, not via the exec function. The reason is the double --
on the login path
option. What makes it hard is that default MySQL
has shorthand option for this -G
, but mysqldump
doesn't!!!
Double dash fails because it's widely used for other things on bash UNIX command prompt. Does anyone know how to get it to work with double --
, or a different workaround?