• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Elias Interactive

We Grow Beautiful Websites

  • Blog
  • Show Search
Hide Search

Magento Database Import Error: USING BTREE, KEY `FK_ATTRIBUTE_VARCHAR_ENTITY` (`entity_id`), KEY `FK_CATALO’ at line 9

Lee Taylor · Dec 1, 2009 · 33 Comments

Tonight I was setting up a staging environment for a client of ours so they would have the ability to “visually” interact with the recent data migration our team has performed (OSCommerce to Magento, in case anyone was wondering).

Here’s the error I was receiving:

ERROR 1064 (42000) at line 382: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘USING BTREE,
KEY `FK_ATTRIBUTE_VARCHAR_ENTITY` (`entity_id`),
KEY `FK_CATALO’ at line 9

The reason behind this is that there is an inconsistency in the way the export syntax was being handled as I imported into the staging environment (which evidently has a different MySQL version running). Thus, the staging site was expecting different syntax for the following:

--
-- Table structure for table `catalog_category_entity_varchar`
--
DROP TABLE IF EXISTS `catalog_category_entity_varchar`;
CREATE TABLE `catalog_category_entity_varchar` (
`value_id` int(11) NOT NULL AUTO_INCREMENT,
`entity_type_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`attribute_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`store_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`entity_id` int(10) unsigned NOT NULL DEFAULT '0',
`value` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`value_id`),
UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`) USING BTREE,
KEY `FK_ATTRIBUTE_VARCHAR_ENTITY` (`entity_id`),
KEY `FK_CATALOG_CATEGORY_ENTITY_VARCHAR_ATTRIBUTE` (`attribute_id`),
KEY `FK_CATALOG_CATEGORY_ENTITY_VARCHAR_STORE` (`store_id`)
) ENGINE=InnoDB AUTO_INCREMENT=697 DEFAULT CHARSET=utf8;

As a rule of thumb, one can either

  • (1) head over to the MySQL Developer Documentation for syntax reference
  • (2) or simply check out a recent Magento export from the server they are trying to import into and determine how the “USING BTREE” statement was handled. Likewise, I simply removed the following:
UNIQUE KEY `IDX_BASE` (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`) USING BTREE,

and replaced it with this:

UNIQUE KEY `IDX_BASE` USING BTREE (`entity_type_id`,`entity_id`,`attribute_id`,`store_id`),

Hope this helps someone who is experiencing the same error and spending way too much time trying to understand the incompatible syntax.

Share this:

  • Tweet
  • Pocket
  • More
  • Email

Blog, Development ERROR 1064 (42000) at line 382: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE, KEY `FK_ATTRIBUTE_VARCHAR_ENTITY` (`entity_id`), KEY `FK_CATALO' at line 9, Magento Database Import Error, Magento database migration

Reader Interactions

Comments

  1. ceddddd says

    December 4, 2009 at 8:50 am

    Very good information thank you its work

    sorry for my english 🙂

    Reply
  2. Michi says

    December 16, 2009 at 10:24 am

    Thank you very much. I thought i’m going crazy on this problem. You saved me a lot of time.

    Reply
  3. Moe says

    December 24, 2009 at 5:29 pm

    THANKS!! You’re a life saver =)

    Reply
  4. ahmed says

    February 2, 2010 at 11:59 pm

    I can’t tell you how much time this saved me! Thanks for the post.

    Reply
  5. nico says

    February 9, 2010 at 11:37 am

    you’re my savior dude..

    Reply
  6. Rob says

    February 23, 2010 at 5:37 am

    Wow, this really saved me some time! I ran into the exact same thing with my Magento store. Thanks a lot for writing this, I would have spent a load of time trying to figure this out…

    Reply
  7. Lee Taylor says

    February 23, 2010 at 2:47 pm

    Great to hear @Rob! Very glad it helped. Feel free to share any findings with us that you deem to be useful for others as well.

    Cheers!

    Reply
  8. Stéphane says

    March 1, 2010 at 12:22 pm

    Just in case you would like more information about this issue, here is the MySQL bug report: http://bugs.mysql.com/bug.php?id=25162. If you have MySQL 5.0.60 and greater (or 5.1.24 and greater), everything should be fine.

    Reply
  9. Lee Taylor says

    March 1, 2010 at 4:05 pm

    Right on @Stéphane! Thanks for sharing.

    Reply
  10. Bravehartk2 says

    March 24, 2010 at 9:24 am

    THX! You saved me a lot of time!!!!

    Reply
  11. diego montero says

    April 10, 2010 at 1:04 pm

    YOU DID IT! Thanks a lot. You saved my life!

    Reply
  12. choussamaster says

    April 13, 2010 at 7:31 am

    thanks very much this work !

    Reply
  13. Kentaur says

    June 24, 2010 at 1:58 pm

    Ty vm, u saved me!

    Reply
  14. Fernando says

    June 27, 2010 at 1:57 am

    Many thanks Lee, save-me a lot

    Cheers

    Reply
  15. Margots says

    July 12, 2010 at 6:43 pm

    Another saved soul

    Reply
  16. Jay says

    July 27, 2010 at 12:56 pm

    You, sir, are a scholar & gentlemen.

    This has probably saved me a ton of hassle.

    Reply
  17. Azhar says

    August 27, 2010 at 1:26 am

    thanks

    Reply
  18. Azhar says

    August 27, 2010 at 1:26 am

    thanks

    Reply
  19. Patrick says

    September 15, 2010 at 10:56 am

    great job man!!

    Reply
  20. Mich says

    October 17, 2010 at 6:59 pm

    Thanks a lot! Just saved me a lot of time!

    Did you ever think about putting flattr on your site? I would definitely flattr this post.

    Reply
  21. Postie says

    November 2, 2010 at 11:11 am

    Thanx a lot man, saved me some nice debugging 🙂 kudo’s

    Reply
  22. Mjjwatson says

    December 15, 2010 at 12:00 pm

    Sir, you are an absolute hero. Thank the heavens for google, and yourself. This is why the world is awesome 🙂

    Reply
  23. Jezza says

    February 17, 2011 at 3:18 pm

    Thank you! worked like a charm. FYI i was moving my db from mysql version 5.1 to 5.0. I haven’t had that problem moving from version 5.0 to 5.1

    Reply
  24. Jimains says

    March 9, 2011 at 11:56 am

    Thank you so much!
    You turned a nightmare of a day in to a good one, very much appreciated

    Reply
  25. Christopher Campbell says

    March 31, 2011 at 7:28 am

    Brilliant. The feeling when I got the error was washed away by your simple and easy to implement solution. Life saver

    Reply
  26. Tyrexwolf says

    May 10, 2011 at 9:05 pm

    Awesome, thank you very much for this tip.

    Reply
  27. Giorgo says

    June 4, 2011 at 7:26 pm

    Thanks

    Reply
  28. Horge20 says

    June 30, 2011 at 1:09 pm

    You are a genius! Worked on this for ages!

    Reply
  29. George says

    August 9, 2011 at 3:59 pm

    Top drawer, sir. Many tanks.

    Reply
  30. peemte says

    September 20, 2011 at 2:12 pm

    Very helpful tip! Thanks a lot, Lee! I was very confusing when I couldn’t restore Joomla database from our testing env (Debian Squeeze with MySQL 5.1.49-3) to production env (Debian Lenny with MySQL 5.0.51a-24+lenny4).

    Reply
  31. Suvidha Cj says

    October 12, 2011 at 8:39 am

    Thank youuuuuuuuuuuuuu 🙂

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

From the blog

Magento SVN Usage – Best Practices

How to Create Reusable Apple Mail Templates [video]

I’d rather buy from Harry Potter

The Ecommerce Solution You’ll Find Refreshing (drumroll)

Liberating Constraints

More Posts

Connect with us

  • Facebook
  • RSS
  • Twitter
Affiliate Disclaimer

© 2025 · Elias Interactive · Built on the Genesis Framework

  • Blog
  • Affiliate Disclaimer
  • Home