HELP - accidentally deleted a database table

by nig
15 replies
OK, first want to say - I know, how stupid was that! I was deleting database tables for a plugin I no longer need and got trigger happy and deleted the wrong one.

The table I deleted by mistake is wp_links - which is now causing massive errors in my error log.
I have saved database backups - how can I get that one table back into my database.

Please be gentle with me, I don't know much about sql's & phpmyadmin ... but can take simple instructions. Any help much appreciated!
#accidentally #database #deleted #table
  • Profile picture of the author timpears
    First thing I would do is ask my host if they could get it out of the back up. Hostgator backs up my site every Saturday morning and sends me a notice to that effect. If you are now with Hostgator, who every you are with must have a backup schedule.
    Signature

    Tim Pears

    {{ DiscussionBoard.errors[6949985].message }}
    • Profile picture of the author nig
      Great thanks for the reply. But I don't want to restore the whole database as I did a whole heap of work on the site in between. I only want the one table wp_links restored ... is that possible at all?
      {{ DiscussionBoard.errors[6949997].message }}
  • Profile picture of the author Dan Grossman
    Yes. Open the backup SQL file and only execute those queries that start with
    Code:
    CREATE TABLE wp_links
    and
    Code:
    INSERT INTO wp_links
    .

    The easiest way to do that is to find those lines, and delete all the stuff before and after them; they will be all together and you don't need the rest of the backup file.

    Then upload to your phpmyadmin, or just pipe the file in to the mysql CLI.
    Signature
    Improvely: Built to track, test and optimize your marketing.

    {{ DiscussionBoard.errors[6950002].message }}
    • Profile picture of the author nig
      Um ... execute? Greatly appreciate your help, but I don't understand what that means. Is that in the phpmyadmin area? And do I "cut and paste" it from notepad?
      Sorry I am such a dumkopf!
      {{ DiscussionBoard.errors[6950008].message }}
      • Profile picture of the author nig
        I have WP Database Manager plugin installed. Can I go to the "run SQL Query" page in my WP dashboard and create the table there?

        It has a CREATE option, but I don't know what to do?

        I have found the piece from inside my sql database: CREATE TABLE etc to INSERT INTO .

        Would I just paste all of that into that WP Database manager page as is?

        Sincerely appreciate any help.
        {{ DiscussionBoard.errors[6953688].message }}
  • Profile picture of the author Dan Grossman
    Sorry, I don't know what these tools are. You want to run those queries.
    Signature
    Improvely: Built to track, test and optimize your marketing.

    {{ DiscussionBoard.errors[6954136].message }}
  • Profile picture of the author nig
    Ok thank you for the replies guys :-)
    {{ DiscussionBoard.errors[6956225].message }}
    • Profile picture of the author homeitservice
      hello nig,
      you have installed WP-DBManager do this first in step by step if no go proceed to the second one and so on...
      1. repair database
      2. restore database if no go
      3. drop/empty tables and run queries

      by the way what version of your DB manager? and you WP?
      {{ DiscussionBoard.errors[6956490].message }}
      • Profile picture of the author nig
        Thank you. I have the latest version of WP & WP Database Manager.

        See, I don't want to re-install the whole database - as I have done a lot of work on the site in the meantime. I only want to re-insert that one, single table: wp_links.

        But I don't fully understand the way to do it. I don't know how to run a query. I can see in WP Database manager where to do it - but don't know exactly what to put into the text box.
        {{ DiscussionBoard.errors[6957089].message }}
  • Profile picture of the author Dan Grossman
    You put the queries you copied out of the backup. You said you found them. The `CREATE TABLE wp_links` and `INSERT INTO wp_links` queries. I'm sure PHPMyAdmin has some tab where you can paste SQL queries in and run them too.
    Signature
    Improvely: Built to track, test and optimize your marketing.

    {{ DiscussionBoard.errors[6958581].message }}
    • Profile picture of the author nig
      Ok, getting there. You guys rock!...

      I pasted the following which is from my database backup, from the start of the CREATE TABLE to the end of the INSERT TABLE into the WP Database manager "Run SQL Query" text box, but it flicked me out to my blog's front page and the table was not added.

      What would be incorrect here, please?

      (I have allowed permissions temporarily in .htaccess and wp-config.php in case that makes a difference)

      CREATE TABLE `wp_links` (
      `link_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
      `link_url` varchar(255) NOT NULL DEFAULT '',
      `link_name` varchar(255) NOT NULL DEFAULT '',
      `link_image` varchar(255) NOT NULL DEFAULT '',
      `link_target` varchar(25) NOT NULL DEFAULT '',
      `link_description` varchar(255) NOT NULL DEFAULT '',
      `link_visible` varchar(20) NOT NULL DEFAULT 'Y',
      `link_owner` bigint(20) unsigned NOT NULL DEFAULT '1',
      `link_rating` int(11) NOT NULL DEFAULT '0',
      `link_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
      `link_rel` varchar(255) NOT NULL DEFAULT '',
      `link_notes` mediumtext NOT NULL,
      `link_rss` varchar(255) NOT NULL DEFAULT '',
      PRIMARY KEY (`link_id`),
      KEY `link_visible` (`link_visible`)
      ) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
      /*!40101 SET character_set_client = @saved_cs_client */;

      --
      -- Dumping data for table `wp_links`
      --

      LOCK TABLES `wp_links` WRITE;
      /*!40000 ALTER TABLE `wp_links` DISABLE KEYS */;
      INSERT INTO `wp_links` VALUES (8,'I DELETED LINK HERE AS NOT ALLOWED/','Techfresh','','_blank','Techfresh','Y',1,0,'000 0-00-00 00:00:00','','','');
      /*!40000 ALTER TABLE `wp_links` ENABLE KEYS */;
      UNLOCK TABLES;
      {{ DiscussionBoard.errors[6960508].message }}
  • Profile picture of the author Dan Grossman
    Perhaps the "WP Database Manager" does not let you run multiple queries at once. Don't use it.
    Signature
    Improvely: Built to track, test and optimize your marketing.

    {{ DiscussionBoard.errors[6960515].message }}
  • {{ DiscussionBoard.errors[6963344].message }}
  • Profile picture of the author websamtron
    I dont think you will get your table back if you dont hve a backup file, so you should create a new table with data in it.
    {{ DiscussionBoard.errors[6967046].message }}
    • Profile picture of the author Dan Grossman
      Originally Posted by websamtron View Post

      I dont think you will get your table back if you dont hve a backup file, so you should create a new table with data in it.
      Why is this forum so infested with new accounts that read nothing and therefore help no one?
      Signature
      Improvely: Built to track, test and optimize your marketing.

      {{ DiscussionBoard.errors[6967151].message }}

Trending Topics