الخلية 1050 خطأ "الجدول موجود بالفعل" عندما في الواقع ، فإنه لا

StackOverflow https://stackoverflow.com/questions/3302476

سؤال

أنا أضيف هذا الجدول:

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-الجدول 'كونتنتتيب' موجود بالفعل

هل كانت مفيدة؟

المحلول

يبدو وكأنه لديك طاولة شرودنجر...

على محمل الجد الآن ، ربما لديك طاولة مكسورة.حاول:

  • DROP TABLE IF EXISTS contenttype
  • REPAIR TABLE contenttype
  • إذا كان لديك أذونات كافية ، حذف ملفات البيانات (في / الخلية / البيانات / اسم دب_)

نصائح أخرى

من سجل mysql:

giveacodicetagpre.

حصلت على هذا الخطأ نفسه ، وإصلاح الجدول (من الإجابة نولوسيركسيبتيون) لم يساعد.

وجدت في النهاية هذا الحل:

sudo mysqladmin flush-tables

بالنسبة لي ، دون sudo, ، حصلت على الخطأ التالي:

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

(يعمل على نظام التشغيل س 10.6)

قد تحتاج إلى مسح ذاكرة التخزين المؤقت للطاولة.على سبيل المثال:

giveacodicetagpre.

لقد كنت أقاتل مع هذا طوال اليوم:لدي برنامج نصي بيرل الذي يبني مجموعة من الجداول عن طريق القيام أولا DROP IF EXISTS ... عليهم ثم CREATEجي لهم.ال DROP نجحت ، ولكن على CREATE تلقيت رسالة الخطأ هذه: table already exists

وأخيرا حصلت على الجزء السفلي منه:الإصدار الجديد من الخلية التي أستخدمها لديه محرك افتراضي من إنودب ("إظهار المحرك \ز؛") لقد غيرت في بلدي.ملف كنف إلى الافتراضي إلى ميسام ، إعادة تشغيل الخلية ، والآن أنا لم يعد الحصول على" الجدول موجود بالفعل " خطأ.

حدثت نفس المشكلة معي أثناء إنشاء عرض. كانت الرأي موجودا في وقت سابق ثم بسبب بعض التغييرات التي تمت إزالتها، لكن عندما حاولت إضافتها مرة أخرى، فقد عرضتني "عرض موجود بالفعل".

الحل :

يمكنك القيام بشيء واحد يدويا.

  1. انتقل إلى مجلد MySQL حيث قمت بتثبيته
  2. انتقل إلى مجلد البيانات داخله.
  3. اختيار قاعدة البيانات الخاصة بك والذهاب داخلها.
  4. قاعدة البيانات تنشئ ملفات تنسيق ".FRM".
  5. حذف ملف الجدول معين.
  6. الآن قم بإنشاء الجدول مرة أخرى.
  7. سينشئ الجدول بنجاح.

مواجهة نفس المشكلة (إنشاء جدول InnoDB) هذا هو ما عمل أخيرا بالنسبة لي:

giveacodicetagpre.

راجعت على أساس ملف، أذونات، حاول إصلاح وتسليف ولكن لا شيء يعمل.

حتى إذا كان هذا خيارا، فقم بتحريك جميع جداول العمل إلى قاعدة بيانات أخرى، إسقاط Old One (قد تضطر إلى إزالة أي ملفات من مجلد قاعدة البيانات قبل انخفاض العمل) ، إعادة تسميةالجديد، وأنت يجب أن تعود في طريقك.على ما يبدو، كل ما يحصل عليه "مخزأ مؤقت" باستخدام InnoDB يتم إسقاطه مع قاعدة البيانات الأصلية.

كان لدي هذه المشكلة على WIN7 في SQL Maestro ل MySQL 12.3.مزعجة بشكل كبير، إظهار سدادة في الواقع.لا شيء ساعد، ولا حتى إسقاط قاعدة البيانات وإعادة إنشاءها.لدي هذا الإعداد نفسه على XP ويعمل هناك، لذلك بعد قراءة إجاباتك حول الأذونات، أدركت أنه يجب أن يكون Win7 أذونات ذات صلة.لذلك ركض Mysql كمسؤول وحتى على الرغم من تشغيل SQL Maestro بشكل طبيعي، اختفى الخطأ.لذلك يجب أن تكون مشكلة أذونات بين Win7 و MySQL.

واجهت أيضا هذه المشكلة حيث تحاول إنشاء جدول قال إنه موجود بالفعل وإسقاط الجدول قال إنه لم يكن موجودا.

قمت ب "طاولات تدفق" وتطهير المشكلة.

أنا أعاني من نفس المشكلة.لا يمكنني إنشاء جدول ، على الرغم من عدم وجوده.لقد جربت جميع الحلول المذكورة أعلاه دون نجاح.

كان الحل الخاص بي هو حذف الملفات ib_logfil0, ib_logfile1, ibdata1, ، و auto.cnf من مجلد البيانات من الخلية;تأكد من إيقاف خدمة الخلية أولا قبل حذف هذه الملفات.

ثم بعد إعادة تشغيل الخدمة ، الخلية صوغه هذه الملفات وكنت قادرا على تشغيل برنامج نصي النسخ الاحتياطي كانت كل ما عندي CREATEتم تخزين الصورة (ملف سكلدومب).

تحقق أولا مما إذا كنت في قاعدة البيانات الصحيحة USE yourDB وحاول Select * from contenttype فقط لمعرفة ما هو عليه ، وإذا كان موجودا حقا...

كان لدي نفس المشكلة في Mac OS X و MySQL 5.1.40.لقد استخدمت الكسوف لتحرير البرنامج النصي SQL وأكثر مما حاولت MySqlworkbench 5.2.28.ربما تحويل أحرف خطوط نيولين إلى تنسيق ماك.لم يكن لدي أي فكرة عن الخطأ في البرنامج النصي الخاص بي حتى علقت على السطر الأول في الملف.بعد هذا البرنامج النصي هذا تم تفسيره بواسطة MySQL كتعليق واحد واحد.لقد استخدمت تطبيق Build-in TextEdit Mac لإصلاح هذا.بعد تحويل استراحات الخط إلى التنسيق الصحيح، ذهب الخطأ 1050.

تحديث للمستخدمين Eclipse:

لإعداد النهاية الافتراضية للملفات الجديدة التي تم إنشاؤها، عبر مساحة العمل بأكملها:

نافذة -> تفضيلات -> عام -> مساحة العمل -> خط ملف نص جديد محدد.

لتحويل الملفات الموجودة، فتح ملف للتحرير والملف المحرر حاليا، انتقل إلى القائمة:

ملف -> محول سيقان المحول إلى

كان لدي هذه الحالة نفسها.انتهت المشكلة أن تكون أذونات على الدليل الأصلي.

كنت قد نسخ الملفات داخل وخارج mysql أثناء الاختبار.

giveacodicetagpre.

لم يكن كافيا، يجب أن يكون:

giveacodicetagpre.

آسف لإحياء.

كنت أواجه مشكلات كبيرة مع الخطأ 1050 و 150.

المشكلة ، بالنسبة لي هي أنني كنت أحاول إضافة قيد مع ON DELETE SET NULL باعتبارها واحدة من الشروط.

تغيير إلى ON DELETE NO ACTION سمح لي لإضافة القيود فك المطلوبة.

للأسف رسائل الخطأ الخلية هي غير مفيدة تماما لذلك كان لي للعثور على هذا الحل بشكل متكرر وبمساعدة من الإجابات على السؤال أعلاه.

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