【发布时间】:2016-09-12 07:15:56
【问题描述】:
MySQL 5.5.46 奇怪错误:表不存在,无法创建。
请问,有人可以帮忙吗?
drop table t_example;
返回:drop table t_example 错误代码:1051. Unknown table 't_example' 0.000 sec
CREATE TABLE t_example(
`id_example` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`des_example` VARCHAR(45) NOT NULL,
`id_example` int unsigned NULL,
PRIMARY KEY (`id_example`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;
返回:错误代码:1050。表 't_example' 已存在
select * from t_example;
返回:错误代码:1146。表 't_example' 不存在
我正在使用:
- UBUNTU 14.04 LTS;
- mysql Ver 14.14 Distrib 5.5.46,适用于使用 readline 6 的 debian-linux-gnu (x86_64)。
- 我使用的是 root 用户。
试过了:
mysql> REPAIR TABLE t_example;
+----------------+--------+----------+--------------------------------------+
| Table | Op | Msg_type | Msg_text |
+ ---------------+--------+----------+--------------------------------------+
| mydb.t_example | repair | Error | Table 'mydb.t_example' doesn't exist |
| mydb.t_example | repair | status | Operation failed |
+----------------+--------+----------+--------------------------------------+
2 rows in set (0.00 sec)
也试过了:sudo mysqladmin flush-tables ...也没有解决问题!
真实示例:
mysql> use flexible;
Database changed
mysql> select * from st_fin_centro_custo;
ERROR 1146 (42S02): Table 'flexible.st_fin_centro_custo' doesn't exist
mysql> CREATE TABLE st_fin_centro_custo(
-> `cod_centro_custo` INT UNSIGNED NOT NULL AUTO_INCREMENT,
-> `des_centro_custo` VARCHAR(45) NOT NULL,
-> PRIMARY KEY (`cod_centro_custo`))
-> ENGINE = InnoDB
-> DEFAULT CHARACTER SET = utf8
-> COLLATE = utf8_general_ci;
ERROR 1050 (42S01): Table '`flexible`.`st_fin_centro_custo`' already exists
mysql> drop table st_fin_centro_custo;
ERROR 1051 (42S02): Unknown table 'st_fin_centro_custo'
mysql>
尝试从 MySQL information_schema 中获取:
mysql> SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_TYPE
FROM information_schema.tables
where table_name like 'st_fin_centro_custo';
Empty set (0.00 sec)
mysql>
注意:使用其他名称创建表可以正常工作。
非常感谢!
【问题讨论】:
-
里面有没有你没有提到的
USE声明? -
请发出命令
show tables;。 -
该表未与“显示表;”一起列出
-
首先,我选择了数据库:use mydatabase;
-
你确定你一直在同一个数据库中吗?