Leave a comment

Import SQL File in MySQL

<?php
    
    $con = mysql_connect(“localhost”, “root”, “admin”) or die(“Database connection failed: “.mysql_error());
    $db = mysql_select_db(“SQL_FILE”, $con) or die(“Database selectio failed: “.mysql_error());

$path = //your file path
$sql_filename = ‘wp_options.sql’;
$sql_contents = file_get_contents($path.$sql_filename);
$sql_contents = explode(“@@”, $sql_contents);
foreach($sql_contents as $query){
       $result = mysql_query($query) or die(“Database query failed: “.mysql_error());
}
?>

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

%d bloggers like this: