Domanda

Sto aggiungendo questa tabella:

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

E ottengo un 1050 "la tabella esiste già"

Ma il tavolo NON esiste.Qualche idea?

MODIFICARE:maggiori dettagli perché tutti sembrano non credermi :)

DESCRIBE contenttype

rendimento:

1146-Tabella ' gunzfact_vbforumdb.contenttype ' non esiste

e

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

Rendimento:

1050-La tabella 'contenttype' esiste già

È stato utile?

Soluzione

Sembra che tu abbia Schroedinger's Table ... Seriamente ora, probabilmente hai un tavolo rotto.Prova:

    .
  • DROP TABLE IF EXISTS contenttype
  • REPAIR TABLE contenttype
  • Se si dispone di autorizzazioni sufficienti, eliminare i file di dati (in / mysql / dati / db_name)

Altri suggerimenti

Da MySQL Log:

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

Ho preso questo stesso errore e la tabella di riparazione (dalla risposta di @ nulluserexception) non ha aiutato.

Alla fine ho trovato Questa soluzione :

sudo mysqladmin flush-tables
.

Per me, senza il sudo, ho ottenuto il seguente errore:

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

(Esecuzione su OS X 10.6)

Potrebbe essere necessario scaricare la cache della tabella.Ad esempio:

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

Ho lottato con questo tutto il giorno:Ho uno script Perl che costruisce una serie di tabelle facendo prima un DROP IF EXISTS ... su di loro e poi CREATEing loro.Il DROP successo, ma su CREATE Ho ricevuto questo messaggio di errore: table already exists

Finalmente sono arrivato a fondo:La nuova versione di MySQL che sto usando ha un motore predefinito di InnoDB ("show engine \ G;") l'ho cambiato nel mio.il file cnf per default su MyISAM, ha riavviato MySQL e ora non ottengo più l'errore "table already exists".

Lo stesso problema si è verificato con me durante la creazione di una vista. La vista era presente in precedenza, quindi a causa di alcuni cambiamenti è stato rimosso ma quando ho provato ad aggiungerlo di nuovo mi stava mostrando "Visualizza già esiste" un messaggio di errore.

Soluzione :

puoi fare una cosa manualmente.

    .
  1. Vai alla cartella MySQL in cui hai installato
  2. Vai alla cartella dati al suo interno.
  3. Scegli il tuo database e vai dentro.
  4. Data Base crea file in formato ".FRM".
  5. Elimina il file della tabella particolare.
  6. Ora crea nuovamente il tavolo.
  7. Creerà la tabella con successo.

che incontra lo stesso problema (creare tavolo InnoDB) Questo è ciò che alla fine ha funzionato per me:

DROP DATABASE `having_issues`;
.

Ho controllato un file BASE, Autorizzazioni, provato a riparare e a filo ma niente ha funzionato.

Quindi se questa è un'opzione, sposta tutte le tabelle di lavoro in un altro database, rilascia il vecchio (potrebbe essere necessario rimuovere manualmente i file dalla cartella del database prima del calo del lavoro) , rinominaIl nuovo, e tu devi 'tornare sulla tua strada.Apparentemente, qualunque cosa arrivi "cache" usando InnoDB viene abbandonato insieme al database originale.

Ho avuto questo problema su Win7 in SQL Maestro per MySQL 12.3.Enormemente irritante, un tappo di spettacolo infatti.Niente ha aiutato, nemmeno cadere e ricreare il database.Ho questa stessa configurazione su XP e funziona lì, quindi dopo aver letto le tue risposte sulle autorizzazioni che ho capito che deve essere relativa alle autorizzazioni vincenti.Quindi ho eseguito MySQL come amministratore e anche se SQL Maestro è stato eseguito normalmente, l'errore è scomparso.Quindi deve essere stato un problema di autorizzazioni tra Win7 e MySQL.

Ho anche incontrato questo problema in cui il tentativo di creare una tabella ha detto che esiste già e lasciando che il tavolo ha detto che non esisteva.

Ho fatto "tavoli da incasso" e ha cancellato il problema.

Sto lottando con lo stesso problema.Non riesco a creare un tavolo, anche se non esiste.Ho provato tutte le soluzioni sopra riportate senza successo.

La mia soluzione era quella di eliminare i file ib_logfil0, ib_logfile1, ibdata1 e auto.cnf della cartella dei dati di MySQL;Assicurati di interrompere il servizio MySQL prima di eliminare questi file.

Poi dopo aver riavviato il servizio, MySQL ha ricreato questi file e sono stato in grado di eseguire uno script di backup sono stati memorizzati tutti i miei CREATEs (un file SQLDUMP).

Prima verifica se si è nel database giusto USE yourDB e prova Select * from contenttype solo per vedere cosa è e se esiste davvero ...

Ho avuto lo stesso problema su Mac OS X e MySQL 5.1.40.Ho usato Eclipse per modificare il mio script SQL e di quanto ho provato MySQLWorkbench 5.2.28.Probabilmente ha convertito i caratteri Newline in formato Mac.Non avevo idea di cosa c'è che non va nel mio script fino a quando non ho commentato la prima riga in file.Dopo questo questo script è stato interpretato da MySQL come un singolo commento.Ho usato l'applicazione Mac di Build-in Textedit Mac per risolvere questo problema.Dopo che le interruzioni di linea sono state convertite nel formato corretto, l'errore 1050 è andato.

Aggiornamento per utenti Eclipse:

Per configurare il finale predefinito per i nuovi file creati, su tutto l'intero spazio di lavoro:

.

Finestra -> Preferenze -> Generale -> Area di lavoro -> Nuova linea di file di testo Delimitatore.

Per convertire i file esistenti, aprire il file per la modifica e per il file attualmente modificato, vai al menu:

.

File -> Converti delimitatori di linea su

Ho avuto questo stesso caso.Il problema è finito per essere autorizzazioni sulla directory principale.

Avevo copiando i file dentro e fuori da MySQL durante il test.

drwx------   3 _mysql  wheel 
.

non era abbastanza, necessario per essere:

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

Ci scusiamo per resuscitare.

Stavo avendo enormi problemi con errore 1050 e 150.

Il problema, per me è stato che stavo cercando di aggiungere un vincolo con ON DELETE SET NULL come una delle condizioni.

Modifica del ON DELETE NO ACTION mi ha permesso di aggiungere i vincoli FK richiesti.

Sfortunatamente i messaggi di errore MySQL sono assolutamente inutili inutilmente, quindi ho dovuto trovare questa soluzione iterativamente e con l'aiuto delle risposte alla domanda sopra.

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top