Read Time1 Minute, 31 Second

If you wanted to import large mysql dump file to database.

See below for how to import mysql dump using only one file.

Step 1: Download dump file. (e.g. demodb.sql).
Step 2: Change connection, username, password, database variable values.
Step 3: Change dump file name with proper path.
Step 4: Run this page.

Import mysql dump file code.

+++++++++++++++++++++++++++++++++++++++++++++++++++++

<?php

$host =”Your Host”;              // Change host (e.g localhost)
$dbusername =”Database username”; // Change Database Username
$dbpassword =”Database password”; // Change Database Password
$database =”Your database”;        // Change Database
$dumpfile = “Your Dump file”;        // Set dump file path (e.g. demodb.sql)
mysql_connect($host,$dbusername,$dbpassword);
mysql_select_db($dumpfile);
$file = fopen($dumpfile, ‘r’);
print ‘<pre>’;
print mysql_error();
$temp = ”;
$count = 0;

while($line = fgets($file)) {
if ((substr($line, 0, 2) != ‘–‘) && (substr($line, 0, 2) != ‘/*’) && strlen($line) > 1) {
$last = trim(substr($line, -2, 1));
$temp .= trim(substr($line, 0, -1));
if ($last == ‘;’) {
mysql_query($temp);
$count++;
$temp = ”;
}
}
}

echo mysql_error();
echo “Total {$count} queries fire(s).\n”;
echo “Enjoing this fastest mysql dump importer..\n”;
echo ‘</pre>’;

?>

+++++++++++++++++++++++++++++++++++++++++++++++++++++

Enjoying this fastest mysql dump importer.


NOTE : Also visit www.dhanashree.com


If you are in need of any
Web Development feel free to Inquire us . Dhanashree Inc. Expertise in Asp.net Development, Php Development,
Website designing
, Open Source customisation. Dhanashree Inc can be our offshore development company /
outsourcing web development company, hire dedicated web programmers.


Above information is for knowledge sharing if you have problem / issue / suggestion please intimate us with details for proper and prompt action.

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Close