質問

このテーブルを追加しています:

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 - Table 'GunzFact_VBForumDB.ContentType'が存在しない

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 - TABLE 'ContentType'は既に存在しています

役に立ちましたか?

解決

あなたのような音があるように聞こえます SchReedingerのテーブル ...

真剣に、あなたはおそらく壊れたテーブルを持っています。試してみてください:

  • 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.
.

私はこれと同じエラーを得て、修理テーブル(@ NullUserExceptionの回答)は役に立たなかった。

最終的に見つかりましたこのソリューション

sudo mysqladmin flush-tables
.

sudoがないと、次のエラーが発生しました:

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

(OS X 10.6の実行)

テーブルキャッシュをフラッシュする必要があるかもしれません。例えば:

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

これは一日中とも戦っています:私は最初にそれらの上にDROP IF EXISTS ...を実行してからそれらをCREATEingすることによって一連のテーブルを構築するPerlスクリプトを持っています。DROPは成功しましたが、CREATEではこのエラーメッセージが表示されます.table already exists

ついにそれの一番下に着いた:私が使用しているMySQLの新しいバージョンのInnoDBのデフォルトエンジンを持っています( "Show Engine \ G;")My.cnfファイルでデフォルトのMyisamに変更しました、MySQLを再起動し、今度は「テーブルが既に存在する」というエラーが発生しなくなりました。

ビューを作成しながら私と同じ問題が発生しました。 ビューは早く存在していました。

溶液

手動で一つのことをすることができます。

  1. インストールしたMySQLフォルダに移動
  2. その中のデータフォルダに移動します。
  3. データベースを選択してその中に入ってください。
  4. データベース ".frm"フォーマットファイルを作成します。
  5. 特定のテーブルのファイルを削除します。
  6. もう一度テーブルを作成します。
  7. テーブルを正常に作成します。

同じ問題に遭遇した(InnoDBテーブルの作成)これが私のためについに働いているものです:

DROP DATABASE `having_issues`;
.

ファイルの基本、権限、修理し、フラッシュしようとしたが、何も機能しない。

だからオプションであれば、すべての作業テーブルを別のデータベースに移動する場合は、古い1つのをドロップします(仕事へのドロップの前にデータベースフォルダからファイルを手動で削除する必要があるかもしれません)、名前の変更新しいもの、そしてあなたはあなたの道に戻るべきです。明らかに、InnoDBを使用して「キャッシュされた」を取得するものは何でも元のデータベースと一緒にドロップされます。

MySQLのSQL MaestroのWin7にこの問題を抱えていました12.3。刺激的な、現実のショーストッパー。データベースを削除して再作成しても、何も役に立ちません。私はXPでこれと同じ設定をしていて、そこで動作します。だから私はMySQLを管理者として実行し、SQL Maestroが正常に実行されたとしても、エラーが消えました。そのため、Win7とMySQLの間のアクセス許可問題がある必要があります。

私はテーブルを作成しようとしていると言ったテーブルを作成しようとしていると言ったテーブルを存在し、それが存在しなかったと言ったという問題が発生しました。

私は「フラッシュテーブル」をやりました、そしてそれは問題を解消しました。

私は同じ問題に苦しんでいます。存在しないにもかかわらずテーブルを作成できません。私は成功しない上記の解決策をすべて試しました。

私の解決策は、MySQLのデータフォルダからib_logfil0ib_logfile1ibdata1、およびauto.cnfを削除することでした。これらのファイルを削除する前に、最初にMySQLサービスを停止してください。

サービスを再起動した後、MySQLはこれらのファイルを再作成し、バックアップスクリプトを実行できました。

最初のチェックあなたが正しいデータベースUSE yourDBにいるかどうかを確認し、それが何であるかを見るためだけに存在するのであれば...

Mac OS XとMySQL 5.1.40で同じ問題がありました。私はEclipseを使用してSQLスクリプトを編集し、MySQLworkbench 5.2.28を試してみました。おそらくそれは改行文字をMAC形式に変換しました。ファイルの最初の行をコメントアウトするまで、私のスクリプトの何が悪いのかについてはわかりませんでした。この後、このスクリプトはMySQLによって1つのコメントとして解釈されました。これを修正するためにBuild-in 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