문제

이 테이블을 추가하고 있습니다:

CREATE TABLE contenttype (
        contenttypeid INT UNSIGNED NOT NULL AUTO_INCREMENT,
        class VARBINARY(50) NOT NULL,
        packageid INT UNSIGNED NOT NULL,
        canplace ENUM('0','1') NOT NULL DEFAULT '0',
        cansearch ENUM('0','1') NOT NULL DEFAULT '0',
        cantag ENUM('0','1') DEFAULT '0',
        canattach ENUM('0','1') DEFAULT '0',
        isaggregator ENUM('0', '1') NOT NULL DEFAULT '0',
        PRIMARY KEY (contenttypeid),
        UNIQUE KEY packageclass (packageid, class)
);

그리고 1050"테이블이 이미 존재합니다"

하지만 테이블은 존재하지 않는다.어떤 아이디어?

편집:모두가 나를 믿지 않는 것처럼 보이기 때문에 더 많은 세부 사항:)

DESCRIBE contenttype

수확량:

1146-테이블'건즈팩트 _포럼.콘텐츠 유형'이 존재하지 않습니다

그리고

CREATE TABLE gunzfact_vbforumdb.contenttype(
contenttypeid INT UNSIGNED NOT NULL AUTO_INCREMENT ,
class VARBINARY( 50 ) NOT NULL ,
packageid INT UNSIGNED NOT NULL ,
canplace ENUM( '0', '1' ) NOT NULL DEFAULT '0',
cansearch ENUM( '0', '1' ) NOT NULL DEFAULT '0',
cantag ENUM( '0', '1' ) DEFAULT '0',
canattach ENUM( '0', '1' ) DEFAULT '0',
isaggregator ENUM( '0', '1' ) NOT NULL DEFAULT '0',
PRIMARY KEY ( contenttypeid ) ,

수확량:

1050-테이블'콘텐츠 유형'이 이미 있습니다.

도움이 되었습니까?

해결책

와 같은 소리 Schroedinger의 테이블 ... 진지하게 지금, 당신은 아마도 깨진 테이블이있을 것입니다.시도해보십시오 :

  • DROP TABLE IF EXISTS contenttype
  • REPAIR TABLE contenttype
  • 충분한 사용 권한이있는 경우 데이터 파일 (/ mysql / data / db_name)
  • 삭제

다른 팁

mysql 로그에서 :

InnoDB: You can drop the orphaned table inside InnoDB by
InnoDB: creating an InnoDB table with the same name in another
InnoDB: database and copying the .frm file to the current database.
InnoDB: Then MySQL thinks the table exists, and DROP TABLE will
InnoDB: succeed.
.

이 같은 오류가 발생했고 복구 테이블은 도움이되지 않았습니다.

나는 결국 발견 이 솔루션:

sudo mysqladmin flush-tables

나를 위해,없이 sudo,나는 다음과 같은 오류가 발생했습니다:

mysqladmin: refresh failed; error: 'Access denied; you need the RELOAD privilege for this operation'

(운영 체제 10.6 에서 실행)

테이블 캐시를 플러시해야 할 수 있습니다.예 :

DROP TABLE IF EXISTS `tablename` ;
FLUSH TABLES `tablename` ; /* or exclude `tablename` to flush all tables */
CREATE TABLE `tablename` ...
.

었으로 싸우는 이 모든 일:나는 Perl 스크립트를 작성하는 설정의 테이블에 의 첫번째 DROP IF EXISTS ... 에서 그들과 다음 CREATEing 니다.이 DROP 성공했지만에 CREATE 이 오류 메시지: table already exists

마지막으로 가지고 그것의 바닥:새로운 버전의 MySQL 는 내가 사용하는 기본적으로 엔진의 InnoDB("보 엔진\G;")에 my.cnf 파일을 기본적으로 MyISAM,다시 시작 MySQL,지금은 더 이상 얻을 수"테이블이 이미 존재"오류가 있습니다.

뷰를 만드는 동안 동일한 문제가 발생했습니다. 이보기는 이전에 나타났습니다. 그러나 그것이 제거 되었기 때문에 다시 추가하려고했을 때 "이미보기"오류 메시지가 나타났습니다.

솔루션 :

수동으로 한 가지 할 수 있습니다.

  1. MySQL 폴더로 이동하여
  2. 를 설치했습니다.
  3. 내부의 데이터 폴더로 이동하십시오.
  4. 데이터베이스를 선택하고 안으로 들어가십시오.
  5. 데이터베이스는 ".FRM"형식 파일을 생성합니다.
  6. 특정 테이블의 파일을 삭제합니다.
  7. 이제 테이블을 다시 작성하십시오.
  8. 테이블이 성공적으로 생성됩니다.

동일한 문제가 발생합니다 (InnoDB Table 만들기) 이것은 마침내 나를 위해 일한 것입니다 :

DROP DATABASE `having_issues`;
.

파일 기반, 사용 권한, 수리 및 플러시를 시도했지만 아무 일도 작동하지 않았습니다.

그래서 옵션 인 경우 모든 작업 테이블을 다른 데이터베이스로 이동하고 이전 하나의 을 삭제하십시오. 을 사용하여 데이터베이스 폴더에서 파일을 수동으로 제거해야 할 수 있습니다.새로운 것이며, 당신은 당신의 방식으로 돌아 가야합니다.분명히 InnoDB를 사용하여 '캐시'를 얻는 것은 원래 데이터베이스와 함께 삭제됩니다.

MySQL 12.3 용 SQL Maestro의 Win7 에서이 문제가있었습니다.거대하게 자극적 인, 사실 쇼 스토퍼.데이터베이스를 떨어 뜨리고 재생성하지 않고 도움이되지 않았습니다.XP에서 동일한 설정을 가지고 있으며 거기에서 작동하므로 사용 권한에 대한 답변을 읽은 후에는 Win7 권한이 있어야한다는 것을 깨달았습니다.따라서 MySQL을 관리자로 실행했으며 SQL Maestro가 정상적으로 실행되었지만 오류가 사라졌습니다.따라서 Win7과 MySQL간에 사용 권한 문제가 있어야합니다.

또한 테이블을 만들려고하는이 문제가 이미 존재하지 않고 테이블이 존재하지 않았다고 말했다.

나는 "테이블을 플러시"하고 문제를 해결했습니다.

나는 같은 문제로 어려움을 겪고 있습니다.존재하지 않더라도 테이블을 만들 수 없습니다.나는 성공하지 못한 모든 솔루션을 모두 시도했습니다.

MySQL의 데이터 폴더에서 ib_logfil0, ib_logfile1, ibdata1auto.cnf 파일을 삭제하는 것이 었습니다.이러한 파일을 삭제하기 전에 MySQL 서비스를 먼저 중지하십시오.

그런 다음 서비스를 다시 시작한 후 MySQL은 이러한 파일을 다시 작성하고 백업 스크립트를 실행할 수있었습니다. 내 CREATEs가 저장되었습니다 (sqldump 파일).

먼저 오른쪽 데이터베이스에 있는지 확인하고 USE yourDB를 확인하고 Select * from contenttype가 무엇인지 확인하고 실제로 존재하는 경우 ...

Mac OS X 및 MySQL 5.1.40에서 동일한 문제가 발생했습니다.나는 Eclipse를 사용하여 내 SQL 스크립트를 편집했고 Mysqlworkbench 5.2.28을 시도하는 것보다.아마도 Newline 문자를 Mac 형식으로 변환 할 수 있습니다.파일의 첫 번째 줄을 껐다가 꺼낼 때까지 내 스크립트에 잘못된 것이 무엇인지 전혀 알지 못했습니다.이 후이 스크립트는 MySQL에서 한 번의 주석으로 해석되었습니다.나는 이것을 고치기 위해 빌드 인 TextEdit Mac 응용 프로그램을 사용했습니다.줄 바꿈이 올바른 형식으로 변환 된 후 오류 1050은 사라졌습니다.

Eclipse 사용자를위한 업데이트 :

전체 작업 공간에서 생성 된 새 파일에 대한 기본 종료를 설정하려면 다음을 수행하십시오.

창 -> 환경 설정 -> 일반 -> 작업 공간 -> 새 텍스트 파일 라인 구분 기호.

기존 파일을 변환하려면 편집을 위해 파일을 열고 현재 편집 된 파일의 메뉴로 이동하십시오.

파일 -> 라인 구분 기호 변환

나는이 같은 사례를 가지고 있었다.문제는 상위 디렉토리에 대한 사용 권한이 종료되었습니다.

테스트 중에 MySQL에서 파일을 복사 해 왔습니다.

drwx------   3 _mysql  wheel 
.

가 충분하지 않았습니다.

-rw-rw----   3 _mysql  wheel 
.

부활해서 죄송합니다.

오류 1050과 150에 큰 문제가있었습니다.

문제가 발생한 문제 중 하나로 ON DELETE SET NULL와 제약 조건을 추가하려고했습니다.

ON DELETE NO ACTION로 변경하면 필수 FK 제약 조건을 추가 할 수있었습니다.

불행히도 MySQL 오류 메시지는 완전히 도움이되지 않으므로이 솔루션을 반복적으로 찾아야했고 위의 질문에 대한 답변을 돕습니다.

I had this same problem and it looks like the Database name was case sensitive. My Database is called:

Mydatabase

Whilst my script included

USE mydatabase

Once I changed the database name to the correct case it all seemed to work. Using MYSQL Workbench on MAC OSX

This problem also occurs if a 'view' (imaginary table) exists in database as same name as our new table name.

In my case I found this to be an issue with InnoDB; I never discovered what the actual problem was, but creating as a MyISAM allowed it to build

For me the problem was caused when using a filesystem copy of the mysql database directory instead of mysqldump. I have some very large tables, mostly MyISAM and a few InnoDB cache tables and it is not practical to mysqldump the data. Since we are still running MyISAM, XtraBackup is not an option.

The same symptoms as above happened to me. The table is not there, there are no files in the directory that pertain to the table, yet it cannot be created because MySQL thinks its there. Drop table says it's not there, create table says it is.

The problem occurred on two machines, both were fixed by copying backups. However, I noticed that in my backup that there was a .MYD and .MYI file, even though I was under the impression that these files are not used for InnoDB. The .MYD and .MYI files had an owner of root, while the .frm was owned by mysql.

If you copy from backup, check the file permissions. Flush tables might work, but I opted to shut down and restart the database.

Good luck.

gosh, i had the same problem with osCommerce install script until i figured out the mysql system has many databases and the create table query copies itself into each one and thus droping only the working table on active db didnt help, i had to drop the table from all dbs

My CREATE statement was part of staging env dump.

I did try everything that has been mentioned above. I DID NOT get solution. However my path to redemption was:

  1. I stumble upon the fact that (one of many in) the CREATE statement did get through when I rectified the database name case sensitivity. This clicked something. I repeated the same for the other tables.

  2. However a new error came into the scene. The straight quotes for 'comments' were throwing syntax error. I was shocked. replaced them but the new error started popping up. Finally i knew the solution.

SOLUTION: The dump i was using might have been from a different version of MySql. I got permission to connect to the staging MYsql using the local(installed on my machine) mysql workbench. I did not rdp into the staging server to login to staging mysql workbench. Created a dump from there. Ran the dump and it worked like a sweet.

Was trying to import a backup sql file but was getting the error; 1050 "Table already exists"

My setup was:

  • Windows 7
  • Mysql 5.5.16

Solution:

  1. Changed the server engine from InnoDB to MyISAM
  2. Using phpMyAdmin Deleted the database I was trying to import to
  3. Restarted the mysql service
  4. Tried the re-importation and it worked

Your disk also might just be full. (just had that)

In my case the problem was that there was a view with the same name as my table, so I had to drop the view to allow the import to continue.

drop view `my-view-that-has-same-name-as-table`;

An automated solution that worked for me is to replace the normal drop table with this sed during the dump to also drop any views that might exist:

mysqldump my-db \
| sed -E 's/^DROP TABLE IF EXISTS(.+)$/\0 DROP VIEW IF EXISTS\1/g' \
| mysql my-other-db

Or if you would rather print to a file for backup

mysqldump my-db \
| sed -E 's/^DROP TABLE IF EXISTS(.+)$/\0 DROP VIEW IF EXISTS\1/g' \
> my-db.dump.sql

Or if you received the dumped file and you are importing it to your db

cat my-db.dump.sql \
| sed -E 's/^DROP TABLE IF EXISTS(.+)$/\0 DROP VIEW IF EXISTS\1/g' \
| mysql my-other-db

You get the idea

Note: it is important that you add the ^ at the beginning of the replacement regex, because there are other types of DROP TABLE IF EXISTS commands in dumps that you don't want to touch.

You go from having something like this:

--
-- Table structure for table `my_table`
--

DROP TABLE IF EXISTS `my_table`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `my_table` (
...

To having something like this:

--
-- Table structure for table `my_table`
--

DROP TABLE IF EXISTS `my_table`; DROP VIEW IF EXISTS `my_table`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `my_table` (
...

You won´t believe me! I´ve just removed a comment block from my .sql file and now it works.

CREATE DATABASE  IF NOT EXISTS `issga` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `issga`;
--
-- Table structure for table `protocolo`
--

DROP TABLE IF EXISTS protocolo;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
 CREATE TABLE protocolo (
  `idProtocolo` int(11) NOT NULL AUTO_INCREMENT,
  `tipo` varchar(30) DEFAULT NULL,
  `estado` int(2) DEFAULT 0,
  PRIMARY KEY (`idProtocolo`)
 ) ENGINE=InnoDB AUTO_INCREMENT=142 DEFAULT CHARSET=utf8;
 /*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `protocolo`
--

LOCK TABLES protocolo WRITE;
/*!40000 ALTER TABLE protocolo DISABLE KEYS */;
/* INSERT INTO `protocolo` VALUES () */
/*!40000 ALTER TABLE protocolo ENABLE KEYS */;
UNLOCK TABLES;

The deleted comment block was this:

--
-- Table structure for table `protocolo`
-- 

I´ve left the problematic table alone in the same .sql file. After that I´ve removed comments, the only code was left, and the error disappears.

I've just had the same error but I knew the table already existed and wanted to add to it. I'm adding my answer as this question comes up as no.1 for me on google when looking for the same error but for a slightly different scenario. Basically I needed to tick

"Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER statement"

And this solved the error for me.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top