Sometimes, you meet in a number of cases that need you to execute SQL file through PHP, in this case MySQL schema. Here is the script I been using until today.
$sqlFileLocation = '/path/to/sql/file.sql'; $sqlFileLocation = getcwd().$sqlFileLocation; $sqlSyntax = "mysql -u$mysql_user -p$mysql_pass $database_name < $sqlFileLocation"; $pid = @popen($sqlSyntax, "r"); @pclose($pid);
safe_mode is enabled, for better security. You could use this script such as for manual backup via web interface. Its even better if you authenticate/filter/limit which user could execute shell command from PHP because the malicious user could inject malicious script to your system. Be aware of that.