Upload large mysql database using php

<?php
ini_set(‘memory_limit’, ‘999M’);
//ENTER THE RELEVANT INFO BELOW
$mysqlDatabaseName = ‘dbname’;
$mysqlUserName = ‘db_user’;
$mysqlPassword = ‘db_password’;
$mysqlHostName = ‘localhost’;
$mysqlImportFilename = ‘db_file.sql’;

//DO NOT EDIT BELOW THIS LINE
//Export the database and output the status to the page
$command = ‘mysql -h’ . $mysqlHostName . ‘ -u’ . $mysqlUserName . ‘ -p’ . $mysqlPassword . ‘ ‘ . $mysqlDatabaseName . ‘ < ‘ . $mysqlImportFilename;
exec($command, $output = array(), $worked);
switch ($worked) {
case 0:
echo ‘Import file ‘ . $mysqlImportFilename . ‘ successfully imported to database ‘ . $mysqlDatabaseName . ‘‘;
break;
case 1:
echo ‘There was an error during import. Please make sure the import file is saved in the same folder as this script and check your values:’;
break;
}
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s