</div>
<div class='post-location'>
</div>
<div class='post-share-buttons goog-inline-block'>
<div class='addthis_native_toolbox'></div>
</div>
<span class='post-icons'>
</span>
<span class='item-control blog-admin pid-1305465561'>
<a href='https://www.blogger.com/post-edit.g?blogID=8188666969217622696&postID=5398728478159007850&from=pencil' title='Edit Post'>
<img alt="" class="icon-action" height="18" src="//img2.blogblog.com/img/icon18_edit_allbkg.gif" width="18">
</a>
</span>
</div>
<div class='post-footer-line post-footer-line-2'></div>
<div class='post-footer-line post-footer-line-3'></div>
<div class='post-footbg'></div>
</div>
<span class='datex hidex'>
<strong></strong>
<span></span>
<small></small>
</span>
</article>
</div>

</div></div>


<div class="date-outer">


<div class="date-posts">

<div class='post-outer'>
<article class='post hentry' id='8466702453615599647' itemscope='' itemtype='http://schema.org/BlogPosting'>
<h2 class='post-title entry-title' itemprop='name headline'>
<a href='https://www.howi.in/2018/07/restore-mysql-database-using-php.html' itemprop='url'>How to Restore Mysql Database Using PHP</a>
</h2>
<div class='post-body entry-content' id='post-body-8466702453615599647' itemprop='description articleBody'>
<textarea id='postData-8466702453615599647' style='display:none;'><div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-KZzCL0lnYlk/W0YNh9L4DoI/AAAAAAAAObs/Z0Kf0g55RYsLlfzBAj1L1nBt6kk1WainwCLcBGAs/s1600/Copy%2Bof%2BWordPress%2B%25281%2529.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="How to Restore Mysql Database Using PHP" border="0" data-original-height="201" data-original-width="820" src="https://1.bp.blogspot.com/-KZzCL0lnYlk/W0YNh9L4DoI/AAAAAAAAObs/Z0Kf0g55RYsLlfzBAj1L1nBt6kk1WainwCLcBGAs/s1600/Copy%2Bof%2BWordPress%2B%25281%2529.png" title="How to Restore Mysql Database Using PHP" /></a></div>
<h4 style="text-align: left;">
Introduction:</h4>
<div>
Hello guys.. Today I am going to share a PHP script that requested by many of My friends and YouTube viewers after creating the tutorial about <a href="http://www.howi.in/2016/12/auto-backup-mysql-database-using-php.html" target="_blank">How to backup MySQL Database using PHP</a>.</div>
<div>
<br /></div>
<div>
In this tutorial you will learn to Re-store MYSQL Database using PHP Script. So, lets get in to the tutorial.&nbsp;</div>
<div>
<h4 style="text-align: left;">
How to Restore Mysql Database Using PHP:</h4>
</div>
<div>
First of all create a page and name it "<b>restore.php</b>" in your public directory and copy the code that I shared below to it.<br />
<div>
<pre class="brush: js;" style="text-align: left;">&lt;?php
$conn = mysqli_connect("localhost", "root", "", "YOUR DATABASE NAME");
$filePath = "Your Database File Here to Backup";
function restoreMysqlDB($filePath, $conn)
{
$sql = '';
$error = '';

if (file_exists($filePath)) {
$lines = file($filePath);

foreach ($lines as $line) {

// Ignoring comments from the SQL script
if (substr($line, 0, 2) == '--' || $line == '') {
continue;
}

$sql .= $line;

if (substr(trim($line), - 1, 1) == ';') {
$result = mysqli_query($conn, $sql);
if (! $result) {
$error .= mysqli_error($conn) . "\n";
}
$sql = '';
}
} // end foreach

if ($error) {
$response = array(
"type" =&gt; "error",
"message" =&gt; $error
);
} else {
$response = array(
"type" =&gt; "success",
"message" =&gt; "Database Restore Completed Successfully."
);
}
} // end if file exists
return $response;
}
restoreMysqlDB($filePath,$conn);
?&gt;</pre>
<ul>
<li>On the above code change the "<b>YOUR DATABASE NAME</b>" with your Database Name.</li>
<li>Change "<b>Your Database File Here to Backup</b>" with the file .SQL File location that you want to Re-Store.</li>
</ul>
<div>
Example: I took a backup of a database name "<b>Accessories</b>" and saved to "<b>c://backup/accessories.sql</b>". Now I am going to edit the script like the following.</div>
<div>
<br /></div>
<div>
Will change the "<b>YOUR DATABASE NAME</b>" with "<b>Accessories</b>" and "<b>Your Database File Here to Backup</b>" with "<b>c://backup/accessories.sql</b>".&nbsp;</div>
<div>
<br /></div>
<div>
Now run the script.. It will take time as per your Database Size.</div>
<iframe allowfullscreen="" frameborder="0" height="350" src="https://www.youtube.com/embed/ogP0yL34QiQ" width="820"></iframe>

<h4 style="text-align: left;">
Topics You May Like to Read:</h4>
<div>
<ul style="text-align: left;">
<li><a href="http://www.howi.in/2018/07/get-browser-name-and-version-using-php-script.html" target="_blank">How to Get Browser Name and Version Using PHP.</a></li>
<li><a href="http://www.howi.in/2018/07/convert-web-application-to-desktop-application.html" target="_blank">How to Convert Web Application to Desktop Application.</a></li>
<li><a href="http://www.howi.in/2017/07/php-code-to-send-sms-to-mobile-from-website-or-localhost.html" target="_blank">PHP Code to Send SMS from Localhost.</a></li>
<li><a href="http://www.howi.in/2017/07/show-div-box-after-click-on-a-button-in-javascript.html" target="_blank">How to Show Div Box After Click on a Button in Java-script.</a></li>
</ul>
<div>
I hope you like this article. Please let me know your comments and feedback by using the comment box that given below. Thank you.</div>
</div>
</div>
</div>
</div>
</textarea>
<div class='post-summary' id='summaryContainer-8466702453615599647'>
<a class='thumbimgx' href='https://www.howi.in/2018/07/restore-mysql-database-using-php.html' target='_blank' title='How to Restore Mysql Database Using PHP'><img alt='How to Restore Mysql Database Using PHP' class='post-thumbnail' height='72' itemprop='image' src='https://1.

Prev | Next
Pg.: 1 ... 8 9 10 11 12 13 14 15 16 17 18 ... 37


Back to home | File page

Subscribe | Register | Login | N