Frage

Ich füge diese Tabelle hinzu:

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)
);

Und ich bekomme eine 1050 „Tabelle existiert bereits“

Aber die Tabelle existiert NICHT.Irgendwelche Ideen?

BEARBEITEN:Mehr Details, weil mir anscheinend nicht jeder glaubt :)

DESCRIBE contenttype

Erträge:

1146 – Tabelle „gunzfact_vbforumdb.contenttype“ existiert nicht

Und

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 ) ,

Erträge:

1050 – Tabelle „contenttype“ existiert bereits

War es hilfreich?

Lösung

klingt wie Sie haben Schröedinger Tabelle ...

.

Nun, jetzt haben Sie wahrscheinlich einen gebrochenen Tisch.Versuchen Sie:

  • DROP TABLE IF EXISTS contenttype
  • REPAIR TABLE contenttype
  • Wenn Sie über ausreichende Berechtigungen verfügen, löschen Sie die Datendateien (in / mysql / data / db_name)

Andere Tipps

aus mySQL-Protokoll:

generasacodicetagpre.

Ich habe den gleichen Fehler erhalten und REPAIR TABLE (aus der Antwort von @NullUserException) hat nicht geholfen.

Ich habe es schließlich gefunden diese Lösung:

sudo mysqladmin flush-tables

Für mich ohne sudo, ich habe die folgende Fehlermeldung erhalten:

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

(Läuft unter OS X 10.6)

Sie müssen möglicherweise den Tabellencache spülen.Zum Beispiel:

generasacodicetagpre.

Ich habe den ganzen Tag damit gekämpft:Ich habe ein Perl-Skript, das eine Reihe von Tabellen erstellt, indem es zunächst Folgendes ausführt: DROP IF EXISTS ... auf sie und dann CREATEing sie.Der DROP gelungen, aber weiter CREATE Ich habe diese Fehlermeldung erhalten: table already exists

Endlich bin ich der Sache auf den Grund gegangen:Die neue Version von MySQL, die ich verwende, verfügt über eine Standard-Engine von InnoDB („show engine \G;“). Ich habe sie in der Datei my.cnf auf die Standardeinstellung MyISAM geändert, MySQL neu gestartet und jetzt bekomme ich nichts mehr der Fehler „Tabelle existiert bereits“

Dasselbe Problem trat bei mir auf, während Sie eine Ansicht erstellen. Die Ansicht war früher anwesend, dann aufgrund einiger Änderungen wurde er entfernt, aber als ich versucht habe, es erneut hinzuzufügen, zeigte es mir, dass mir ein "Ansicht ist bereits vorhanden". Fehlermeldung.

Lösung :

Sie können manuell eine Sache tun.

    .
  1. Zum MySQL-Ordner, in dem Sie es installiert haben
  2. Gehen Sie in den Datenordner darin.
  3. Wählen Sie Ihre Datenbank und gehen Sie hinein.
  4. Datenbank erstellt ".frm-Formatdateien.
  5. Löschen Sie die Datei der Tabelle.
  6. Erstellen Sie jetzt den Tisch erneut.
  7. Es erstellt die Tabelle erfolgreich.

auf das gleiche Problem auftreten (Erstellen von Innodb-Tisch) Dies ist, was endlich für mich funktioniert hat:

generasacodicetagpre.

Ich habe auf einer Datei, Berechtigungen überprüft, um zu reparieren und zu bündig zu reparieren, aber nichts hat funktioniert.

Wenn dies eine Option ist, bewegen Sie alle Arbeitstabellen in eine andere Datenbank, lassen Sie den alten ein (Möglicherweise müssen Sie möglicherweise Dateien aus dem Datenbankordner manuell entfernen, bevor Sie arbeiten) , umbenennenDie neue, und Sie sollten auf dem Weg zurück sein.Anscheinend wird mit der ursprünglichen Datenbank zusammen mit der ursprünglichen Datenbank gefallen.

Ich hatte dieses Problem bei Win7 in SQL Maestro für MySQL 12.3.Enorm irritierend, ein Showstopper in der Tat.Nichts half, nicht einmal zu fallen und die Datenbank neu zu erstellen.Ich habe das gleiche Setup auf XP und es funktioniert dort, also nachdem ich Ihre Antworten über Berechtigungen gelesen habe, erkannte ich, dass es Win7-Berechtigungen zusammenhängen muss.Also lief ich MySQL als Administrator und obwohl SQL Maestro normal ausgeführt wurde, ist der Fehler verschwunden.Es muss also ein Berechtigungs-Problem zwischen Win7 und MySQL gewesen sein.

Ich habe auch dieses Problem angetroffen, an dem er versucht, eine Tabelle zu erstellen, sagte, dass es bereits existiert und den Tisch lief, sagte, es existierte nicht.

Ich habe "spülen Tabellen" und es löste das Problem.

Ich kämpfe mit dem gleichen Problem.Ich kann keine Tabelle erstellen, obwohl sie nicht existiert.Ich habe alle oben genannten Lösungen ohne Erfolg ausprobiert.

Meine Lösung bestand darin, die Dateien zu löschen ib_logfil0, ib_logfile1, ibdata1, Und auto.cnf aus dem Datenordner von MySQL;Stellen Sie sicher, dass Sie zuerst den MySQL-Dienst stoppen, bevor Sie diese Dateien löschen.

Dann, nach dem Neustart des Dienstes, hat MySQL diese Dateien neu erstellt und ich konnte ein Backup-Skript ausführen, das alle meine Dateien waren CREATEs wurden gespeichert (eine sqldump-Datei).

Überprüfen Sie zunächst, ob Sie sich in der richtigen Datenbank befinden USE yourDB und versuche Select * from contenttype Nur um zu sehen, was es ist und ob es wirklich existiert ...

Ich hatte das gleiche Problem bei Mac OS X und MySQL 5.1.40.Ich habe Eclipse verwendet, um mein SQL-Skript zu bearbeiten, und ich habe mysqlworkbench 5.2.28 versucht.Wahrscheinlich konvertierte es neue Figuren-Zeichen in das Mac-Format.Ich hatte keine Ahnung, was mit meinem Skript falsch ist, bis ich die erste Zeile in der Datei kommentierte.Danach wurde dieses Skript von MySQL als ein einzelner Kommentar interpretiert.Ich habe eine Build-In-TextEntit-MAC-Anwendung verwendet, um dies zu beheben.Nachdem die Zeilenumbrüche in das richtige Format konvertiert wurden, ist der Fehler 1050 weggegangen.

update für eclipse-Benutzer:

So richten Sie das Standardende für neue Dateien auf, in dem er erstellt wurde, über den gesamten Arbeitsbereich:

Fenster -> Voreinstellungen -> Allgemein -> Arbeitsbereich -> Neue Textdateizeile Trennzeichen.

Um vorhandene Dateien zu konvertieren, zu öffnen, die Datei zum Bearbeiten und für die aktuell bearbeitete Datei öffnen, zum Menü gehen:

Datei -> Zeilenräume konvertieren in

Ich hatte den gleichen Fall.Das Problem endete die Berechtigungen auf dem übergeordneten Verzeichnis.

Ich hatte während des Tests in MySQL-Dateien in MySQL kopiert.

generasacodicetagpre.

war nicht genug, musste sein:

generasacodicetagpre.

Es tut mir leid, dass es wiederbelebt wird.

Ich hatte große Probleme mit den Fehlern 1050 und 150.

Das Problem bestand für mich darin, dass ich versuchte, eine Einschränkung hinzuzufügen ON DELETE SET NULL als eine der Bedingungen.

Wechseln zu ON DELETE NO ACTION erlaubte mir, die erforderlichen FK-Einschränkungen hinzuzufügen.

Leider sind die MySql-Fehlermeldungen überhaupt nicht hilfreich, sodass ich diese Lösung iterativ und mithilfe der Antworten auf die obige Frage finden musste.

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top