Loading...

Forum Index > Web Development > Upload database mysql lebih cepat dan tanpa batas MB

host4secure 35 months ago
ActivityRank: 0
Biasanya, untuk upload file mysql menggunakan cara standard via phpmyadmin akan dibatasi oleh jumlah MB. Besar sedikit aja dia sudah tidak mau. Tapi ada solusi untuk upload database mysql berukuran besar. Caranya, pakai scrip dump spt di bawah ini. Copy script di bawah ini di notepad, kemudian save as sebagai bigdump.php. Terus login ke cpanel, buka file manager, buat folder di bawah "www" dengan nama "bigdump". Setelah itu buka folder bigdump, dan upload file bigdump. Tentu saja uploadnya setalah Anda mengisi beberapa isian yang diperlukan di dalamnya. Upload juga database mysql yang akan diupload, biasanya berekstensi .gz, .sql, atau .sql.gz. Setelah diupload dan udah diisi informasi mengenai database (nama db, username, password, nama database yang akan dibackup), buka browser dan eksekusi dengan cara mengakses www.namadomain.com/big...gdump.php. Selanjutnya tinggal ikuti perintah di situ. SELESAI..... Setelah selesai, jangan lupa delete folder bigdump beserta isinya. $val) { $val = preg_replace("/[^_A-Za-z0-9-\.&=]/i",'', $val); $_REQUEST[$key] = $val; } ?>
'); } function skin_close() { echo (''); } skin_open(); echo ('

BigDump: Staggered MySQL Dump Importer v'.VERSION.'

'); skin_close(); $error = false; $file = false; // Check PHP version if (!$error && !function_exists('version_compare')) { echo ("

PHP version 4.1.0 is required for BigDump to proceed. You have PHP ".phpversion()." installed. Sorry!

\n"); $error=true; } // Calculate PHP max upload size (handle settings like 10M or 100K) if (!$error) { $upload_max_filesize=ini_get("upload_max_filesize"); if (eregi("([0-9]+)K",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024; if (eregi("([0-9]+)M",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024; if (eregi("([0-9]+)G",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024*1024; } // Get the current directory if (isset($_SERVER["CGIA"])) $upload_dir=dirname($_SERVER["CGIA"]); else if (isset($_SERVER["ORIG_SCRIPT_FILENAME"])) $upload_dir=dirname($_SERVER["ORIG_SCRIPT_FILENAME"]); else if (isset($_SERVER["PATH_TRANSLATED"])) $upload_dir=dirname($_SERVER["PATH_TRANSLATED"]); else $upload_dir=dirname($_SERVER["SCRIPT_FILENAME"]); // Handle file upload if (!$error && isset($_REQUEST["uploadbutton"])) { if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"])==0) { $uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]); $uploaded_filename=preg_replace("/[^_A-Za-z0-9-\.]/i",'',$uploaded_filename); $uploaded_filepath=str_replace("\\","/",$upload_dir."/".$uploaded_filename); if (file_exists($uploaded_filename)) { echo ("

File $uploaded_filename already exist! Delete and upload again!

\n"); } else if (!eregi("(\.(sql|gz))$",$uploaded_filename)) { echo ("

You may only upload .sql or .gz files.

\n"); } else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath)) { echo ("

Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath

\n"); echo ("

Check the directory permissions for $upload_dir (must be 777)!

\n"); } else { echo ("

Uploaded file saved as $uploaded_filename

\n"); } } else { echo ("

Error uploading file ".$_FILES["dumpfile"]["name"]."

\n"); } } // Handle file deletion (delete only in the current directory for security reasons) if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"])) { if (eregi("(\.(sql|gz))$",$_REQUEST["delete"]) && @unlink(basename($_REQUEST["delete"]))) echo ("

".$_REQUEST["delete"]." was removed successfully

\n"); else echo ("

Can't remove ".$_REQUEST["delete"]."

\n"); } // Connect to the database if (!$error && !TESTMODE) { $dbconnection = @mysql_connect($db_server,$db_username,$db_password); if ($dbconnection) $db = mysql_select_db($db_name); if (!$dbconnection || !$db) { echo ("

Database connection failed due to ".mysql_error()."

\n"); echo ("

Edit the database settings in ".$_SERVER["SCRIPT_FILENAME"]." or contact your database provider

\n"); $error=true; } if (!$error && $db_connection_charset!=='') @mysql_query("SET NAMES $db_connection_charset", $dbconnection); } else { $dbconnection = false; } // List uploaded files in multifile mode if (!$error && !isset($_REQUEST["fn"]) && $filename=="") { if ($dirhandle = opendir($upload_dir)) { $dirhead=false; while (false !== ($dirfile = readdir($dirhandle))) { if ($dirfile != "." && $dirfile != ".." && $dirfile!=basename($_SERVER["SCRIPT_FILENAME"])) { if (!$dirhead) { echo ("\n"); echo ("\n"); $dirhead=true; } echo (""); if (eregi("\.sql$",$dirfile)) echo (""); elseif (eregi("\.gz$",$dirfile)) echo (""); else echo (""); if ((eregi("\.gz$",$dirfile) && function_exists("gzopen")) || eregi("\.sql$",$dirfile)) echo ("\n \n"); else echo ("\n \n"); } } if ($dirhead) echo ("
FilenameSizeDate&TimeType
$dirfile".filesize($dirfile)."".date ("Y-m-d H:i:s", filemtime($dirfile))."SQLGZipMiscStart Import into $db_name at $db_serverDelete file
\n"); else echo ("

No uploaded files found in the working directory

\n"); closedir($dirhandle); } else { echo ("

Error listing directory $upload_dir

\n"); $error=true; } } // Single file mode if (!$error && !isset ($_REQUEST["fn"]) && $filename!="") { echo ("

Start Import from $filename into $db_name at $db_server

\n"); } // File Upload Form if (!$error && !isset($_REQUEST["fn"]) && $filename=="") { // Test permissions on working directory do { $tempfilename=time().".tmp"; } while (file_exists($tempfilename)); if (!($tempfile=@fopen($tempfilename,"w"))) { echo ("

Upload form disabled. Permissions for the working directory $upload_dir must be set to 777 in order "); echo ("to upload files from here. Alternatively you can upload your dump files via FTP.

\n"); } else { fclose($tempfile); unlink ($tempfilename); echo ("

You can now upload your dump file up to $upload_max_filesize bytes (".round ($upload_max_filesize/1024/1024)." Mbytes) "); echo ("directly from your browser to the server. Alternatively you can upload your dump files of any size via FTP.

\n"); ?>
" enctype="multipart/form-data">

Dump file:

Note: The current mySQL connection charset is $charset. Your dump file must be encoded in $charset in order to avoid problems with non-latin characters. You can change the connection charset using the \$db_connection_charset variable in bigdump.php

\n"); } } // Open the file if (!$error && isset($_REQUEST["fn"])) { // Recognize GZip filename if (eregi("\.gz$",$_REQUEST["fn"])) $gzipmode=true; else $gzipmode=false; if ((!$gzipmode && !$file=fopen($_REQUEST["fn"],"rt")) || ($gzipmode && !$file=gzopen($_REQUEST["fn"],"rt"))) { echo ("

Can't open ".$_REQUEST["fn"]." for import

\n"); echo ("

You have to upload the ".$_REQUEST["fn"]." to the server

\n"); $error=true; } // Get the file size (can't do it fast on gzipped files, no idea how) else if ((!$gzipmode && fseek($file, 0, SEEK_END)==0) || ($gzipmode && gzseek($file, 0)==0)) { if (!$gzipmode) $filesize = ftell($file); else $filesize = gztell($file); // Always zero, ignore } else { echo ("

I can't get the filesize of ".$_REQUEST["fn"]."

\n"); $error=true; } } // **************************************************** // START IMPORT SESSION HERE // **************************************************** if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && eregi("(\.(sql|gz))$",$_REQUEST["fn"])) { // Check start and foffset are numeric values if (!is_numeric($_REQUEST["start"]) || !is_numeric($_REQUEST["foffset"])) { echo ("

UNEXPECTED: Non-numeric values for start and foffset

\n"); $error=true; } if (!$error) { $_REQUEST["start"] = floor($_REQUEST["start"]); $_REQUEST["foffset"] = floor($_REQUEST["foffset"]); skin_open(); if (TESTMODE) echo ("

TEST MODE ENABLED

\n"); echo ("

Processing file: ".$_REQUEST["fn"]."

\n"); echo ("

Starting from line: ".$_REQUEST["start"]."

\n"); skin_close(); } // Check $_REQUEST["foffset"] upon $filesize (can't do it on gzipped files) if (!$error && !$gzipmode && $_REQUEST["foffset"]>$filesize) { echo ("

UNEXPECTED: Can't set file pointer behind the end of file

\n"); $error=true; } // Set file pointer to $_REQUEST["foffset"] if (!$error && ((!$gzipmode && fseek($file, $_REQUEST["foffset"])!=0) || ($gzipmode && gzseek($file, $_REQUEST["foffset"])!=0))) { echo ("

UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."

\n"); $error=true; } // Start processing queries from $file if (!$error) { $query=""; $queries=0; $totalqueries=$_REQUEST["totalqueries"]; $linenumber=$_REQUEST["start"]; $querylines=0; $inparents=false; // Stay processing as long as the $linespersession is not reached or the query is still incomplete while ($linenumber<$_REQUEST["start"]+$linespersession || $query!="") { // Read the whole next line $dumpline = ""; while (!feof($file) && substr ($dumpline, -1) != "\n") { if (!$gzipmode) $dumpline .= fgets($file, DATA_CHUNK_LENGTH); else $dumpline .= gzgets($file, DATA_CHUNK_LENGTH); } if ($dumpline==="") break; // Handle DOS and Mac encoded linebreaks (I don't know if it will work on Win32 or Mac Servers) $dumpline=ereg_replace("\r\n$", "\n", $dumpline); $dumpline=ereg_replace("\r$", "\n", $dumpline); // DIAGNOSTIC // echo ("

Line $linenumber: $dumpline

\n"); // Skip comments and blank lines only if NOT in parents if (!$inparents) { $skipline=false; reset($comment); foreach ($comment as $comment_value) { if (!$inparents && (trim($dumpline)=="" || strpos ($dumpline, $comment_value) === 0)) { $skipline=true; break; } } if ($skipline) { $linenumber++; continue; } } // Remove double back-slashes from the dumpline prior to count the quotes ('\\' can only be within strings) $dumpline_deslashed = str_replace ("\\\\","",$dumpline); // Count ' and \' in the dumpline to avoid query break within a text field ending by ; // Please don't use double quotes ('"')to surround strings, it wont work $parents=substr_count ($dumpline_deslashed, "'")-substr_count ($dumpline_deslashed, "\\'"); if ($parents % 2 != 0) $inparents=!$inparents; // Add the line to query $query .= $dumpline; // Don't count the line if in parents (text fields may include unlimited linebreaks) if (!$inparents) $querylines++; // Stop if query contains more lines as defined by MAX_QUERY_LINES if ($querylines>MAX_QUERY_LINES) { echo ("

Stopped at the line $linenumber.

"); echo ("

At this place the current query includes more than ".MAX_QUERY_LINES." dump lines. That can happen if your dump file was "); echo ("created by some tool which doesn't place a semicolon followed by a linebreak at the end of each query, or if your dump contains "); echo ("extended inserts. Please read the BigDump FAQs for more infos.

\n"); $error=true; break; } // Execute query if end of query detected (; as last character) AND NOT in parents if (ereg(";$",trim($dumpline)) && !$inparents) { if (!TESTMODE && !mysql_query(trim($query), $dbconnection)) { echo ("

Error at the line $linenumber: ". trim($dumpline)."

\n"); echo ("

Query: ".trim(nl2br(htmlentities($query)))."

\n"); echo ("

MySQL: ".mysql_error()."

\n"); $error=true; break; } $totalqueries++; $queries++; $query=""; $querylines=0; } $linenumber++; } } // Get the current file position if (!$error) { if (!$gzipmode) $foffset = ftell($file); else $foffset = gztell($file); if (!$foffset) { echo ("

UNEXPECTED: Can't read the file pointer offset

\n"); $error=true; } } // Print statistics skin_open(); // echo ("

Statistics

\n"); if (!$error) { $lines_this = $linenumber-$_REQUEST["start"]; $lines_done = $linenumber-1; $lines_togo = ' ? '; $lines_tota = ' ? '; $queries_this = $queries; $queries_done = $totalqueries; $queries_togo = ' ? '; $queries_tota = ' ? '; $bytes_this = $foffset-$_REQUEST["foffset"]; $bytes_done = $foffset; $kbytes_this = round($bytes_this/1024,2); $kbytes_done = round($bytes_done/1024,2); $mbytes_this = round($kbytes_this/1024,2); $mbytes_done = round($kbytes_done/1024,2); if (!$gzipmode) { $bytes_togo = $filesize-$foffset; $bytes_tota = $filesize; $kbytes_togo = round($bytes_togo/1024,2); $kbytes_tota = round($bytes_tota/1024,2); $mbytes_togo = round($kbytes_togo/1024,2); $mbytes_tota = round($kbytes_tota/1024,2); $pct_this = ceil($bytes_this/$filesize*100); $pct_done = ceil($foffset/$filesize*100); $pct_togo = 100 - $pct_done; $pct_tota = 100; if ($bytes_togo==0) { $lines_togo = '0'; $lines_tota = $linenumber-1; $queries_togo = '0'; $queries_tota = $totalqueries; } $pct_bar = "
"; } else { $bytes_togo = ' ? '; $bytes_tota = ' ? '; $kbytes_togo = ' ? '; $kbytes_tota = ' ? '; $mbytes_togo = ' ? '; $mbytes_tota = ' ? '; $pct_this = ' ? '; $pct_done = ' ? '; $pct_togo = ' ? '; $pct_tota = 100; $pct_bar = str_replace(' ',' ','[ Out of order for gziped files ]'); } echo ("
SessionDoneTo goTotal
Lines$lines_this$lines_done$lines_togo$lines_tota
Queries$queries_this$queries_done$queries_togo$queries_tota
Bytes$bytes_this$bytes_done$bytes_togo$bytes_tota
KB$kbytes_this$kbytes_done$kbytes_togo$kbytes_tota
MB$mbytes_this$mbytes_done$mbytes_togo$mbytes_tota
%$pct_this$pct_done$pct_togo$pct_tota
% bar$pct_bar
\n"); // Finish message and restart the script if ($linenumber<$_REQUEST["start"]+$linespersession) { echo ("

Congratulations: End of file reached, assuming OK

\n"); echo ("

Thank you for using this tool! Please rate Bigdump at Hotscripts.com

\n"); echo ("

You can send me some bucks or euros as appreciation via PayPal

\n"); $error=true; } else { if ($delaypersession!=0) echo ("

Now I'm waiting $delaypersession milliseconds before starting next session...

\n"); echo ("\n"); echo ("\n"); echo ("

Press STOP to abort the import OR WAIT!

\n"); } } else echo ("

Stopped on error

\n"); skin_close(); } if ($error) echo ("

Start from the beginning (DROP the old tables before restarting)

\n"); if ($dbconnection) mysql_close(); if ($file && !$gzipmode) fclose($file); else if ($file && $gzipmode) gzclose($file); ?>

© 2003-2006 Alexey Ozerov - BigDump Home

Hmmm walau udah dikasih tanda code tapi tetap berantakan ya scriptnya, hasil jelasnya silakan Cek DI SINI.

Latest Activity

posted a new message Upload database mysql lebih cepat dan tanpa batas MB.
35 months ago
posted a new message Peluang Bisnis: Reseller server radio streaming.
35 months ago
posted a new message Cara membuat database MySQL via cpanel .
35 months ago
posted a new message Tukeran BackLink (Link Exchange) yukkk.
35 months ago
posted a new message Gratis Managed DNS untuk setiap registrasi domain.
35 months ago
posted a new message Gratis privacy protection untuk tiap domain.
35 months ago
posted a new message HARGA BARU: Hosting Lebih Murah (Now harga USA = IIX).
35 months ago

Top Contributors

12
host4secure

Share