Performed a bad import to my Wordpress install and decided to restore from the mqSQL backup (full export) I had made minutes earlier.

Dropped all tables in the database and then did an import from my .sql file.

I encounter the error below in PHPmyAdmin and find that only 22 of my 44 tables were imported, so I assume the import was aborted.

Was my MySQL db backup corrupt or something? The export/download seemed to go smoothly. My error is #1064, You have an error in your SQL syntax, check the manual... (see image)

Charset appears to be UTF-8 and I'm importing in UTF-8

-- Host: localhost
-- Generation Time: Apr 15, 2013 at 07:01 PM
-- Server version: 5.5.23
-- PHP Version: 5.2.17

SET time_zone = "+00:00";

/*!40101 SET NAMES utf8 */;

sql import error

  • I'm thinking it might be the the importer's inability to read the charset, and now it's confused, trying to parse html instead of a mysql query, but I'm pretty sure I always work in UTF-8. What other charset would I use? – Orun Apr 16 '13 at 1:05
  • Import doesn't work with latin-1 charset (iso 8859-1) either. – Orun Apr 16 '13 at 1:21

Figured it out upon examining my SQL file. It begins as SQL, and near the end changes to PHP. For some reason the download got messed up and the SQL export began outputting the PHP of the PHPmyAdmin page I was on! (not even just the client side HTML, it was spitting out server side PHP).

Anyways, my backup is corrupt. I had to restore from another database backup and now I need to puzzle piece content together from the last couple of days.

Here's the code from the bottom of my SQL file, just for reference (preceding lines are regular SQL output, 19 MB of text content).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="icon" href="./favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="phpmyadmin.css.php?server=1&amp;token=6a3930a6cce9b6bf3d9810d8f65e3f1c&amp;js_frame=right&amp;nocache=5412529155" />
    <link rel="stylesheet" type="text/css" href="print.css" media="print" />
    <link rel="stylesheet" type="text/css" href="./themes/pmahomme/jquery/jquery-ui-1.8.custom.css" />
    <meta name="robots" content="noindex,nofollow" />
<script src="./js/cross_framing_protection.js?ts=1344778698" type="text/javascript"></script>
<script src="./js/jquery/jquery-1.4.4.js?ts=1344778698" type="text/javascript"></script>
<script src="./js/update-location.js?ts=1344778698" type="text/javascript"></script>
<script src="./js/config.js?ts=1344778698" type="text/javascript"></script>
<script src="./js/functions.js?ts=1344778698" type="text/javascript"></script>
<script src="./js/jquery/jquery.qtip-1.0.0.min.js?ts=1344778698" type="text/javascript"></script>
<script src="./js/messages.php?lang=en&amp;db=advdly_adaily&amp;token=6a3930a6cce9b6bf3d9810d8f65e3f1c" type="text/javascript"></script>
<script type="text/javascript">
// <![CDATA[
// Updates the title of the frameset if possible (ns4 does not allow this)
if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
    && typeof(parent.document.title) == 'string') {
    parent.document.title = 'www.advocatedaily.com / localhost / advdly_adaily / wp_rg_form | phpMyAdmin';

// ]]>
        <meta name="OBGZip" content="true" />
                <!--[if IE 6]>
        <style type="text/css">
        /* <![CDATA[ */
        html {
            overflow-y: scroll;
        /* ]]> */

            <div id="prefs_autoload" class="notice" style="display:none">
        <form action="prefs_manage.php" method="post">
            <input type="hidden" name="token" value="6a3930a6cce9b6bf3d9810d8f65e3f1c" />
            <input type="hidden" name="json" value="" />
            <input type="hidden" name="submit_import" value="1" />
            <input type="hidden" name="return_url" value="export.php?" />
            Your browser has phpMyAdmin configuration for this domain. Would you like to import it for current session?            <br />
            <a href="#yes">Yes</a> / <a href="#no">No</a>
    <div id="serverinfo">
<a href="main.php?token=6a3930a6cce9b6bf3d9810d8f65e3f1c" class="item">        <img class="icon" src="./themes/pmahomme/img/s_host.png" width="16" height="16" alt="" /> 
        <span class="separator"><img class="icon" src="./themes/pmahomme/img/item_ltr.png" width="5" height="9" alt="-" /></span>
<a href="db_structure.php?db=advdly_adaily&amp;token=6a3930a6cce9b6bf3d9810d8f65e3f1c" class="item">        <img class="icon" src="./themes/pmahomme/img/s_db.png" width="16" height="16" alt="" /> 
        <span class="separator"><img class="icon" src="./themes/pmahomme/img/item_ltr.png" width="5" height="9" alt="-" /></span>
<a href="sql.php?db=advdly_adaily&amp;table=wp_rg_form&amp;token=6a3930a6cce9b6bf3d9810d8f65e3f1c" class="item">        <img class="icon" src="./themes/pmahomme/img/s_tbl.png" width="16" height="16" alt="" /> 
<!-- PMA-SQL-ERROR -->
    <div class="error"><h1>Error</h1>
    <p><strong>SQL query:</strong>
<a href="tbl_sql.php?sql_query=SHOW+TABLE+STATUS+FROM+%60advdly_adaily%60+LIKE+%27wp_rg_form%27&amp;show_query=1&amp;db=advdly_adaily&amp;table=wp_rg_form&amp;token=6a3930a6cce9b6bf3d9810d8f65e3f1c"><span class="nowrap"><img src="./themes/pmahomme/img/b_edit.png" title="Edit" alt="Edit" class="icon" width="16" height="16" /> Edit</span></a>    </p>
        <span class="syntax"><span class="inner_sql"><a href="./url.php?url=http%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.5%2Fen%2Fshow.html&amp;token=6a3930a6cce9b6bf3d9810d8f65e3f1c" target="mysql_doc"><span class="syntax_alpha syntax_alpha_reservedWord">SHOW</span></a>  <span class="syntax_alpha syntax_alpha_reservedWord">TABLE</span>  <span class="syntax_alpha syntax_alpha_reservedWord">STATUS</span>  <span class="syntax_alpha syntax_alpha_reservedWord">FROM</span>  <span class="syntax_quote syntax_quote_backtick">`advdly_adaily`</span>  <span class="syntax_alpha syntax_alpha_reservedWord">LIKE</span>  <span class="syntax_quote syntax_quote_single">'wp_rg_form'</span></span></span>
    <strong>MySQL said: </strong><a href="./url.php?url=http%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.5%2Fen%2Ferror-messages-server.html&amp;token=6a3930a6cce9b6bf3d9810d8f65e3f1c" target="mysql_doc"><img class="icon" src="./themes/pmahomme/img/b_help.png" width="11" height="11" alt="Documentation" title="Documentation" /></a>
#2006 - MySQL server has gone away
</code><br />
</div><script type="text/javascript">
// updates current settings
if (window.parent.setAll) {
    window.parent.setAll('en', 'utf8_general_ci', '1', 'advdly_adaily', 'wp_rg_form', '6a3930a6cce9b6bf3d9810d8f65e3f1c');
    // set current db, table and sql query in the querywindow
if (window.parent.reload_querywindow) {

if (window.parent.frame_content) {
    // reset content frame name, as querywindow needs to set a unique name
    // before submitting form data, and navigation frame needs the original name
    if (typeof(window.parent.frame_content.name) != 'undefined'
     && window.parent.frame_content.name != 'frame_content') {
        window.parent.frame_content.name = 'frame_content';
    if (typeof(window.parent.frame_content.id) != 'undefined'
     && window.parent.frame_content.id != 'frame_content') {
        window.parent.frame_content.id = 'frame_content';
    //window.parent.frame_content.setAttribute('name', 'frame_content');
    //window.parent.frame_content.setAttribute('id', 'frame_content');


Is the <!DOCTYPE... at the beginning of your sql statement? It's getting choked up trying to read html as sql commands.

I would try making a copy of the file as a backup, then remove the HTML code from the beginning. A SQL backup file usually starts with commented code then a table creation statement like:

  • No, it begins with proper SQL metadata specifying the database, MySQL version, charset, etc. Then it moves on through the entries, table by table. Eventually, near the end, it just switches to PHP. – Orun Apr 16 '13 at 13:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.