Missing Tables From Database - How to Check Dump File Using Grep

  • 7019206
  • 04-Mar-2015
  • 07-Aug-2017


MySQL 5.x


My company had a power outage and the Retain database had issues afterwards and would not start up correctly.  I restored the database from a MySQL dump but is still having issues.  It appears that some tables are missing.  What do I do?


First check the dump to see if it has the appropriate commands from creating the tables:
grep -n 'CREATE TABLE' [dump filename].sql > greptable.txt
If all of the tables are listed in the dump, then it was not a matter of the CREATE TABLE statement missing.  Either something went wrong with the import process or you may want to read the dump in an editor that can handle huge files and verify that all the necessary parameters are listed after the CREATE TABLE for the tables that are missing.

You could also try re-importing the dump and see if it works the second time.

It is recommended that the dump and/or the import of the dump be down on the server console itself; however, if a terminal session is all you have and you are using PuTTY, use the "screen" command so that the session does not close (thus killing the dump or import) if there is an interruption to the terminal session.
Screen Command  - Keeps a terminal session open even if the shell gets closed.

To start a session:
  1. In a terminal window, type screen and press ENTER.
  2. Hit CTRL-A to send a command to the “screen” session.
  • New window:  CTRL-A c
  • Move to next window:  CTRL-A n
  • Move to previous window:  CTRL-A p
To restore a session (if the terminal window gets closed): 
  1. Login to a new terminal session.
  2. Type: screen -r
To stop a session, simply type exit in a terminal window.

Additional Information

This article was originally published in the GWAVA knowledgebase as article ID 2491.