HELP - accidentally deleted a database table

by 15 replies
18
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!
#programming #accidentally #database #deleted #table
  • 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.
    • [1] reply
    • 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?
  • 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.
    • [1] reply
    • 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!
      • [1] reply
  • Sorry, I don't know what these tools are. You want to run those queries.
  • Banned
    [DELETED]
  • Ok thank you for the replies guys :-)
    • [1] reply
    • 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?
      • [1] reply
  • 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.
    • [1] reply
    • 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;
  • Perhaps the "WP Database Manager" does not let you run multiple queries at once. Don't use it.
  • You can run the querys from within PHPmyADMIN yes. In the SQL tab.
  • 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.
    • [1] reply
    • Why is this forum so infested with new accounts that read nothing and therefore help no one?

Next Topics on Trending Feed

  • 18

    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.