代码改变世界

mysqldump:Couldn't execute 'show create table `tablename`': Table tablename' doesn't exist (1146)

2015-11-15 09:45  潇湘隐者  阅读(11169)  评论(2编辑  收藏  举报

遇到了一个错误mysqldump: Couldn't execute 'show create table `CONCURRENCY_ERRORS`': Table INVOICE_OLD.CONCURRENCY_ERRORS' doesn't exist (1146)

###### WARNING ######

Errors reported during AutoMySQLBackup execution.. Backup failed

Error log below..

Error: Couldn't read status information for table CONCURRENCY_ERRORS ()

mysqldump: Couldn't execute 'show create table `CONCURRENCY_ERRORS`': Table INVOICE_OLD.CONCURRENCY_ERRORS' doesn't exist (1146)

Error: Couldn't read status information for table CONCURRENCY_ERRORS ()

mysqldump: Couldn't execute 'show create table `CONCURRENCY_ERRORS`': Table INVOICE_OLD.CONCURRENCY_ERRORS' doesn't exist (1146)

数据库的版本为: 5.5.22-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

如下所示,查询不了该表的定义以及数据(都提示该表不存在),但是使用show table like命令又能看到该表。

mysql> USE INVOICE_OLD;
Database changed
mysql> show tables like '%CONCURRENCY_ERRORS%';
+----------------------------------------------+
| Tables_in_INVOICE_OLD (%CONCURRENCY_ERRORS%) |
+----------------------------------------------+
| CONCURRENCY_ERRORS                           |
+----------------------------------------------+
1 row in set (0.73 sec)
 
mysql> select count(1) from CONCURRENCY_ERRORS;
ERROR 1146 (42S02): Table 'INVOICE_OLD.CONCURRENCY_ERRORS' doesn't exist
mysql> desc CONCURRENCY_ERRORS;
ERROR 1146 (42S02): Table 'INVOICE_OLD.CONCURRENCY_ERRORS' doesn't exist
mysql> 

clip_image001

查看对应表的.frm文件(.frm文件是用来保存每个数据表的元数据(meta)信息,包括表结构的定义等),如下所示,发现该文件是存在的。

mysql> show variables like '%datadir%';
+---------------+------------------+
| Variable_name | Value            |
+---------------+------------------+
| datadir       | /u01/mysql/data/ |
+---------------+------------------+
1 row in set (0.23 sec)
 
mysql> exit
Bye
-bash-3.2$ cd /u01/mysql/data
-bash-3.2$ ls CONCURRENCY_ERRORS*
CONCURRENCY_ERRORS.frm

Google查了一下资料,发现这个可能是一个bug来的(详情请见链接https://bugs.mysql.com/bug.php?id=65670 ) 因为这个数据库其实早就迁移走,数据库也被我重命名了。检查发现迁移后的数据库里面,该表没有任何数据。于是我尝试从数据库的数据目录删除了CONCURRENCY_ERRORS.frm文件,备份就不会出现这种情况了。但是没有搞清楚这种情况出现的前因后果。