Question

Je suis en ajoutant ce tableau:

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

Et je reçois un 1050 "table existe déjà"

Mais la table n'existe PAS.Des idées?

EDIT:plus de détails parce que tout le monde semble me croyez pas :)

DESCRIBE contenttype

rendements:

1146 - Table 'gunzfact_vbforumdb.contenttype' n'existe pas

et

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

Rendements:

1050 - Table 'contenttype' existe déjà

Était-ce utile?

La solution

sonne comme si vous avez Table de Schroedinger ...

Sérieusement maintenant, vous avez probablement une table brisée.Essayez:

  • DROP TABLE IF EXISTS contenttype
  • REPAIR TABLE contenttype
  • Si vous avez des autorisations suffisantes, supprimez les fichiers de données (IN / MYSQL / DATA / DB_NAME)

Autres conseils

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

J'ai eu ce même message d'erreur, et de la RÉPARATION de la TABLE (à partir de @NullUserException réponse) n'a pas aidé.

J'ai finalement trouvé cette solution:

sudo mysqladmin flush-tables

Pour moi, sans l' sudo, J'ai obtenu l'erreur suivante:

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

(Système d'exploitation OS X 10.6).

Vous devrez peut-être voler le cache de table.Par exemple:

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

Je me bats avec cette journée:J'ai un script Perl qui construit un ensemble de tables d'abord un DROP IF EXISTS ... sur eux et ensuite CREATEing eux.L' DROP réussi, mais sur CREATE J'ai eu ce message d'erreur: table already exists

J'ai enfin réussi à le fond de celui-ci:La nouvelle version de MySQL que j'utilise est un moteur par défaut de InnoDB ("show engine \G;") je l'ai changé dans mon.cnf de fichier par défaut en MyISAM, re-commencé à MySQL, et maintenant je n'ai plus la "table existe déjà erreur".

Même problème s'est produit avec moi tout en créant une vue. La vue était présente plus tôt puis en raison de quelques modifications qu'elle a été supprimée, mais lorsque j'ai essayé de l'ajouter à nouveau, il me faisait me montrer "la vue existant déjà" message d'erreur.

solution :

Vous pouvez faire une chose manuellement.

  1. Allez dans le dossier MySQL où vous l'avez installé
  2. Allez dans le dossier de données à l'intérieur.
  3. Choisissez votre base de données et allez à l'intérieur.
  4. La base de données crée des fichiers de format ".frm".
  5. Supprimez le fichier de la table concernée.
  6. crée maintenant la table à nouveau.
  7. Cela créera la table avec succès.

rencontrer le même problème (créer une table innodb) C'est ce qui a finalement fonctionné pour moi:

DROP DATABASE `having_issues`;

J'ai vérifié sur une base de fichier, des autorisations, essayé de réparer et de rincer mais rien n'a fonctionné.

Donc, s'il s'agit d'une option, déplacez toutes les tables de travail dans une autre base de données, déposez l'ancien (vous devrez peut-être supprimer manuellement tous les fichiers du dossier de base de données avant la chute du travail) , renommerle nouveau et vous devez être de retour sur votre chemin.Apparemment, tout ce qui obtient «mis en cache» à l'aide d'InnoDB est tombé avec la base de données d'origine.

J'ai eu ce problème sur Win7 dans SQL Maestro pour MySQL 12.3.Énormément irritant, un bouchon de spectacle en fait.Rien n'a aidé, pas même de tomber et de recréer la base de données.J'ai cette même configuration sur XP et cela fonctionne là-bas, alors après avoir lu vos réponses sur les autorisations, j'ai réalisé qu'il doit s'agir de Win7 autorisations liées.J'ai donc ran mysql en tant qu'administrateur et même si SQL Maestro était exécuté normalement, l'erreur a disparu.Cela devait donc être une question d'autorisations entre Win7 et MySQL.

J'ai également rencontré ce problème lorsque vous essayez de créer une table indiquée qu'il existe déjà et dépose la table indiquée qu'il n'existait pas.

J'ai fait "tables de rinçage" et cela a effacé le problème.

Je suis aux prises avec le même problème.Je ne peux pas créer une table, même si elle n'existe pas.J'ai essayé toutes les solutions ci-dessus, sans succès.

Ma solution a été de supprimer les fichiers ib_logfil0, ib_logfile1, ibdata1, et auto.cnf à partir du dossier de données de MySQL;assurez-vous d'arrêter le service MySQL première avant la suppression de ces fichiers.

Puis après le redémarrage du service, MySQL recréé ces fichiers et j'ai été en mesure d'exécuter un script de sauvegarde étaient tous mes CREATEs ont été stockées (un sqldump fichier).

Vérifiez d'abord si vous êtes dans le droit de la base de données USE yourDB et essayer Select * from contenttype juste pour voir ce que c'est, et si elle existe vraiment...

J'ai eu le même problème sur Mac OS X et MySQL 5.1.40.J'ai utilisé Eclipse pour modifier mon script SQL et que j'ai essayé MySQLworkbench 5.2.28.Il a probablement converti des caractères transversaux en format Mac.Je n'avais aucune idée de ce qui ne va pas avec mon script avant d'avoir commenté la première ligne dans le fichier.Après cela, mon script a été interprété par MySQL comme un seul commentaire.J'ai utilisé l'application Mac TextDit de Construction-in TextDit pour résoudre ce problème.Une fois que les pauses de ligne ont été converties au format correct, l'erreur 1050 a disparu.

Mise à jour des utilisateurs Eclipse:

Pour configurer la fin par défaut pour les nouveaux fichiers créés, sur l'ensemble de l'espace de travail:

fenêtre -> Préférences -> Général -> Espace de travail -> Nouvelle ligne de fichier texte Délimiteur.

Pour convertir les fichiers existants, ouvrez le fichier pour l'édition et pour le fichier actuellement édité, allez au menu:

Fichier -> Convertir des délimiteurs de ligne en

J'ai eu ce même cas.Le problème a fini par être des autorisations sur le répertoire parent.

J'avais copié des fichiers dans et hors de MySQL pendant les tests.

drwx------   3 _mysql  wheel 

n'était pas suffisant, devait être:

-rw-rw----   3 _mysql  wheel 

Désolé de ressusciter.

J'ai eu d'énormes problèmes avec l'Erreur 1050 et 150.

Le problème, pour moi, c'était que j'étais en train d'ajouter une contrainte avec ON DELETE SET NULL en tant que l'une des conditions.

Changement de ON DELETE NO ACTION m'a permis d'ajouter la FK contraintes.

Malheureusement, les messages d'erreur MySql qui sont totalement inutile, j'ai donc dû trouver cette solution de manière itérative, avec l'aide de la réponse à la question ci-dessus.

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top