I'm trying to restore MySQL dump created the following way:
$file = '/path/to/file.sql';
exec('mysqldump -u '.DB_USER.' -p'.DB_PASS.' '.DB_NAME.' > '.$file);
the above creates the dump as expected, then to restore I'm trying to use the following:
$file = '/path/to/file.sql';
exec('mysql -u '.DB_USER.' -p'.DB_PASS.' '.DB_NAME.' < '.$file);
but for some reason it doesn't do anything.
Please note that the constants contain the relevant database connection parameters.
Any idea what I'm doing wrong?
解决方案
use mysql -e 'source $file' instead of redirection