Restoring database after reinstallation of MySQL

时间:2017-07-11 08:05:12

标签: mysql database

I had to reinstall MySQL some time ago, before doing it I had moved /var/lib/mysql/mydatabase to another directory to be able to restore it after installation of MySQL. After I installed MySQL I moved back this directory. When I go to mysql console and use

SHOW DATABASES;

it returns list of databases and 'mydatabase' is among the list. When I switch to using 'mydatabase' and use

SHOW TABLES;

it shows the list of tables, but when I do any SELECT command I get this error:

ERROR 1146 (42S02): Table 'mydatabase.mytable1' doesn't exist

From the very beginning - was it enough to backup only /var/lib/mysql/< DATABASE_NAME > to restore database data or have I missed something? If yes then what I could try to fix this issue with 'table doesn't exist'?

MySQL version is 5.7, OS is Ubuntu 16.04

1 个答案:

答案 0 :(得分:1)

MySQL 5.7默认存储引擎是InnoDB。这将数据存储在ibdata,ib_logfile0和ib_logfile1中。如果尚未备份这些文件,则无法还原数据。

可以建议不要移动数据库文件,而应使用mysqldump实用程序。

最好使用innodb-file-per-table,它可以将InnoDB表存储在每个表的.ibd文件中。