{"id":81,"date":"2009-04-09T07:02:53","date_gmt":"2009-04-09T13:02:53","guid":{"rendered":"http:\/\/thenoyes.com\/littlenoise\/?p=81"},"modified":"2015-03-16T11:39:21","modified_gmt":"2015-03-16T16:39:21","slug":"errno-121-duplicate-key-with-create-table","status":"publish","type":"post","link":"https:\/\/thenoyes.com\/littlenoise\/?p=81","title":{"rendered":"errno: 121 (Duplicate key) with CREATE TABLE"},"content":{"rendered":"<p>Trying to create a table, and getting something like this?<\/p>\n<pre>ERROR 1005 (HY000): Can't create table '&lt;db&gt;.&lt;table&gt;' (errno: 121)<\/pre>\n<p>Discovered that perror 121 says this?<\/p>\n<pre>MySQL error code 121: Duplicate key on write or update<\/pre>\n<p>Really confused how you might get a duplicate key error while creating a table?<\/p>\n<p>If the table you&#8217;re trying to create includes a foreign key constraint, and you&#8217;ve provided your own name for that constraint, remember that it must be unique within the database. Run this query to see if that name is in use somewhere:<\/p>\n<pre>SELECT \r\n  constraint_name,\r\n  table_name\r\nFROM \r\n  information_schema.table_constraints \r\nWHERE \r\n  constraint_type = 'FOREIGN KEY' \r\n  AND table_schema = DATABASE() \r\nORDER BY \r\n  constraint_name;<\/pre>\n<p>(If you&#8217;re still on 4.1 or earlier, <\/p>\n<pre>mysqldump --no-data yourDbName | grep CONSTRAINT<\/pre>\n<p> to get a similar list)<\/p>\n<p>Thanks to [raymond] on Freenode.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Trying to create a table, and getting something like this? ERROR 1005 (HY000): Can&#8217;t create table &#8216;&lt;db&gt;.&lt;table&gt;&#8217; (errno: 121) Discovered that perror 121 says this? MySQL error code 121: Duplicate key on write or update Really confused how you might get a duplicate key error while creating a table? If the table you&#8217;re trying to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8],"tags":[],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-mysql-faq"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2IBF1-1j","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=81"}],"version-history":[{"count":2,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":364,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions\/364"}],"wp:attachment":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}