Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7765759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:14:39+00:00 2026-06-01T15:14:39+00:00

Ok, this is the situation. I have backed up my database by going into

  • 0

Ok, this is the situation. I have backed up my database by going into phpMyAdmin and then, without selecting any database, clicking export. Now when I try importing the exported sql file into a fresh MySQL installation, I’m getting errors like
http://pastebin.com/vDHdG2T6 (used pastebin as it’s pretty long)

I know I should have used mysqldump instead as it would skip the information_schema table.
Do you have any suggestions how to solve this or import that file without having to edit the million lines file?

I’ve also tried importing the file like:
mysql -u root -p -f -h localhost < Documents/localhost.sql
This did import the the databases but many of them were corrupt, missing tables and such…I used the -f so it would keep going regardless of errors.

Thanks in advance!

EDIT:

Thank you guys for the suggestions, I’m sure you were on the right track. However, in the meantime I ended up messing up my backup file as well so I had to write a little php code to extract the lines I need.
Here it is in case someone has the same problem:

$data = file_get_contents('import.sql');


if (! isset($_GET['db'])) {
    //list databases
    echo '<ul>';
    preg_match_all("/Database: `(.*?)`/", $data, $dbs);

    foreach ($dbs[1] as $database){
        echo "<li><a href=\"index.php?db=$database\">$database</a></li>";
    }
    echo '</ul>';
} else {
    $database = $_GET['db'];
    //only get the queries for that db
    $data = explode(PHP_EOL, $data);
    $buffer = array();
    $buffer_started = false;

    foreach ($data as $key => $row){

        if (preg_match("/Database: `.*?`/", $row) && $buffer_started) {
            array_pop($buffer);
            break;
        }

        if (preg_match("/Database: `$database`/", $row)) {
            $buffer_started = true;
            continue;
        }

        if ($buffer_started) {
            array_push($buffer, $row);
        }


        unset($data[$key]);
    }

    echo '<textarea cols="128" rows="20">'.implode("\n", $buffer).'</textarea>';
}

Save this as index.php and put your sql into import.sql in the same directory, it will list the databases found in file and just click on whichever you want and it will show the queries in a textarea.

Good luck.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:14:40+00:00Added an answer on June 1, 2026 at 3:14 pm

    As suggested by beanland, I will answer my own question, with a slightly modified code from the above edit:

    error_reporting(E_ALL);
    $data = file_get_contents('import.sql');
    
    
    if (! isset($_GET['db'])) {
        //list databases
        echo '<ul>';
        preg_match_all("/Database: `(.*?)`/", $data, $dbs);
    
        foreach ($dbs[1] as $database){
            echo "<li><a href=\"index.php?db=$database\">$database</a></li>";
        }
        echo '</ul>';
    } else {
        $database = $_GET['db'];
        //only get the queries for that db
        $data = explode(PHP_EOL, $data);
        $buffer = array();
        $buffer_started = false;
    
        foreach ($data as $key => $row){
    
            if (preg_match("/Database: `.*?`/", $row) && $buffer_started) {
                array_pop($buffer);
                break;
            }
    
            if (preg_match("/Database: `$database`/", $row)) {
                $buffer_started = true;
                continue;
            }
    
            if ($buffer_started) {
                array_push($buffer, $row);
            }
    
    
            unset($data[$key]);
        }
    
        $data = implode("\n", $buffer);
    
        //convert all InnoDB to MyISAM
    
        $data = str_replace('InnoDB', 'MyISAM', $data);
    
        echo '<a href="index.php">Back</a><h1>'.$database.'</h1><textarea cols="128" rows="20">'.$data.'</textarea>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this situation I have two models, Comment and Score. The relationship is defined
I have this situation: { float foo[10]; for (int i = 0; i <
I have this situation where I want to display a list of Administration objects
We have this situation: Window Keyboard ^ ^ | / ApplicationWindow so class Window
I have this situation: interface MessageListener { void onMessageReceipt(Message message); } class MessageReceiver {
I have this situation: There are a login page with a login form (form
I have this situation where i have to start an activity from my mainActivity.
I have this situation: web application with cca 200 concurent requests (Threads) are in
this is my situation: I have two org.w3c.dom.Document created from two xml files. What
This is a pretty odd situation I have here. I have used a piece

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.