rits
rits

Reputation: 1544

MySQL ERROR 1146 table doesn't exist after backup

In school after every lesson I need to backup my database so I copy database from mysql data directory and when I work again I paste it back in.

The thing is that I always get error that my tables don't exist although when I type show tables; it lists them.

mysql> show tables;
+--------------------------+
| Tables_in_database_name  |
+--------------------------+
| table_name               |
+--------------------------+
1 row in set (0.00 sec)

I get the error when I type something like this for example:

describe table_name;
ERROR 1146 (42502): Table 'database_name.table_name' doesn't exist

Is there a way to fix this or what would be the proper way to backup my database?

Upvotes: 0

Views: 3830

Answers (1)

Chong Tang
Chong Tang

Reputation: 2146

If you used a InnoDB table, and you just copied the database_name file, you will get the crazy error.

What you need to do is to copy your database_name file along with ib* files. Those ib* files are in the root of the MySQL datadir (like ibdata1, ib_logfile0, or ib_logfile1).

Upvotes: 3

Related Questions