The following script allows you to execute an sql dump file (for instance produced with mysqldump or phpmyadmin).
<?php $mysqli = new mysqli('localhost', 'username', 'password', 'databasename'); if (mysqli_connect_error()) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } echo 'Success... ' . $mysqli->host_info . "<br />"; echo 'Retrieving dumpfile' . "<br />"; $sql = file_get_contents('../dump/caldata.sql'); if (!$sql){ die ('Error opening file'); } echo 'processing file <br />'; mysqli_multi_query($mysqli,$sql); echo 'done.'; $mysqli->close(); ?>
Mysqli_multi_query doesnt seem to handle Alter table queries correctly. It breaks when trying to set innodb constraints with alter table.
Setting delimiters for events also seems to cause problems.