Can't create table 'qqapp.#sql-2f7c_1e' (errno: 150)

来源:互联网 发布:mac spaces 编辑:程序博客网 时间:2024/06/06 01:42
<div id="article_details" class="details">
    <div class="article_title">   
         <span class="ico ico_type_Repost"></span>


    <h1>
        <span class="link_title"><a href="/xtm_rongbing/article/details/8773403">
        Can't create table #sql-2e4_14.frm' (errno: 150)            
        </a></span>
    </h1>
</div>

   

        <div class="article_manage clearfix">
        <div class="article_r">
            <span class="link_postdate">2013-04-08 17:04</span>
            <span class="link_view" title="阅读次数">1993人阅读</span>
            <span class="link_comments" title="评论次数"> <a href="#comments" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_pinglun'])">评论</a>(0)</span>
            <span class="link_collect tracking-ad" data-mod="popu_171"> <a href="javascript:void(0);" onclick="javascript:collectArticle('Can%27t+create+table+%23sql-2e4_14.frm%27+(errno%3a+150)','8773403');return false;" title="收藏" target="_blank">收藏</a></span>
             <span class="link_report"> <a href="#report" onclick="javascript:report(8773403,2);return false;" title="举报">举报</a></span>

        </div>
    </div>
    <div class="embody" style="display:none" id="embody">
        <span class="embody_t">本文章已收录于:</span>
        <div class="embody_c" id="lib" value="{&quot;err&quot;:0,&quot;msg&quot;:&quot;ok&quot;,&quot;data&quot;:[]}"></div>
    </div>
    <style type="text/css">        
            .embody{
                padding:10px 10px 10px;
                margin:0 -20px;
                border-bottom:solid 1px #ededed;                
            }
            .embody_b{
                margin:0 ;
                padding:10px 0;
            }
            .embody .embody_t,.embody .embody_c{
                display: inline-block;
                margin-right:10px;
            }
            .embody_t{
                font-size: 12px;
                color:#999;
            }
            .embody_c{
                font-size: 12px;
            }
            .embody_c img,.embody_c em{
                display: inline-block;
                vertical-align: middle;               
            }
             .embody_c img{               
                width:30px;
                height:30px;
            }
            .embody_c em{
                margin: 0 20px 0 10px;
                color:#333;
                font-style: normal;
            }
    </style>
    <script type="text/javascript">
        $(function () {
            try
            {
                var lib = eval("("+$("#lib").attr("value")+")");
                var html = "";
                if (lib.err == 0) {
                    $.each(lib.data, function (i) {
                        var obj = lib.data[i];
                        //html += '&lt;img src="' + obj.logo + '"/&gt;' + obj.name + "&amp;nbsp;&amp;nbsp;";
                        html += ' &lt;a href="' + obj.url + '" target="_blank"&gt;';
                        html += ' &lt;img src="' + obj.logo + '"&gt;';
                        html += ' &lt;em&gt;&lt;b&gt;' + obj.name + '&lt;/b&gt;&lt;/em&gt;';
                        html += ' &lt;/a&gt;';
                    });
                    if (html != "") {
                        setTimeout(function () {
                            $("#lib").html(html);                      
                            $("#embody").show();
                        }, 100);
                    }
                }      
            } catch (err)
            { }
            
        });
    </script>
      <div class="category clearfix">
        <div class="category_l">
           <img src="http://static.blog.csdn.net/images/category_icon.jpg">
            <span>分类:</span>
        </div>
        <div class="category_r">
                    <label onclick="GetCategoryArticles('1373996','xtm_rongbing','top','8773403');">
                        <span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_fenlei']);">mysql<em>(13)</em></span>
                      <img class="arrow-down" src="http://static.blog.csdn.net/images/arrow_triangle _down.jpg" style="display:inline;">
                      <img class="arrow-up" src="http://static.blog.csdn.net/images/arrow_triangle_up.jpg" style="display:none;">
                        <div class="subItem">
                            <div class="subItem_t"><a href="http://blog.csdn.net/xtm_rongbing/article/category/1373996" target="_blank">作者同类文章</a><i class="J_close">X</i></div>
                            <ul class="subItem_l" id="top_1373996">                            
                            </ul>
                        </div>
                    </label>                    
        </div>
    </div>

 

 
 
     


<div id="article_content" class="article_content tracking-ad" data-mod="popu_307" data-dsm="post">

<p>转载自:<a href="http://hi.baidu.com/jnshiyanlvting/item/27e86091a6a72bd11a49df20" target="_blank">http://hi.baidu.com/jnshiyanlvting/item/27e86091a6a72bd11a49df20</a></p>
<p>&nbsp;</p>
<p>This is a very common error when create a <a href="http://lib.csdn.net/base/mysql" class="replace_word" title="MySQL知识库" target="_blank" style="color:#df3434; font-weight:bold;">MySQL</a> table , even some people has take it as a <a href="http://lib.csdn.net/base/mysql" class="replace_word" title="MySQL知识库" target="_blank" style="color:#df3434; font-weight:bold;">mysql</a> bug and commit it to the official , I came up with this bothered problem these days also, after a crazy Google work, the source of the problem became clear ,
 the following lines is a very good article that give that "bug" a conclusion , and I'd like to translate it into simple Chinese in case you'll hit that problem again ,</p>
<p></p>
<p>Concerning the personal talent, some mistakes can not be avoid , if you found any, please feel free to contact me , or leave a message below, thanks in advance.<br>
source url :</p>
<p><a href="http://www.verysimple.com/blog/2006/10/22/mysql-error-number-1005-cant-create-table-mydbsql-328_45frm-errno-150/" target="_blank">http://www.verysimple.com/blog/2006/10/22/mysql-error-number-1005-cant-create-table-mydbsql-328_45frm-errno-150/</a></p>
<p></p>
<p></p>
<p>Translation text :</p>
<p></p>
<p>当你试图在mysql中创建一个外键的时候,这个出错会经常发生,这是非常令人沮丧的。像这种不能创建一个.frm 文件的报错好像暗示着<a href="http://lib.csdn.net/base/operatingsystem" class="replace_word" title="操作系统知识库" target="_blank" style="color:#df3434; font-weight:bold;">操作系统</a>的文件的权限错误或者其它原因,但实际上,这些都不是的,事实上,这个mysql报错已经被报告是一个mysql本身的bug并出现在mysql 开发者列表当中很多年了,然而这似乎又是一种误导。</p>
<p></p>
<p>在很多实例中,这种错误的发生都是因为mysql一直以来都不能很好的支持的关系的问题, 更不幸的是它也并没有指明到底是哪一个问题会导致上面那种错误,下面我把导致这个可怕 的150错误的常见原因列出来了,并且我以可能性的大小作了排序</p>
<p></p>
<p>已知的原因:</p>
<p></p>
<p>1, 两个字段的类型或者大小不严格匹配,例如,如果一个是INT(10), 那么外键也必须设置成INT(10), 而不是 INT(11) 也不能是 TINYINT. 你得使用 SHOW 命令来查看字段的大小,因为一些查询浏览器有时候把 int(10) 和int(11) 都显示为integer。另外,你还必须确定两个字段是否一个为 SIGNED,而另一个又是UNSIGNED, 这两字段必须严格地一致匹配,更多关于signed 和 unsigned 的信息,请参阅:<a href="http://www.verysimple.com/blog/?p=57" target="_blank">http://www.verysimple.com/blog/?p=57</a></p>
<p></p>
<p>2, 你试图引用的其中一个外键没有建立起索引,或者不是一个primary key , 如果其中一个不是primary key 的放,你必须为它创建一个索引。</p>
<p></p>
<p>3, 外键的名字是一个已经存在的一个键值了,这个时候,你应该检查你的<a href="http://lib.csdn.net/base/mysql" class="replace_word" title="MySQL知识库" target="_blank" style="color:#df3434; font-weight:bold;">数据库</a>以确保外健名字是唯一的,或者你在键名后面加上几个随机的字符以<a href="http://lib.csdn.net/base/softwaretest" class="replace_word" title="软件测试知识库" target="_blank" style="color:#df3434; font-weight:bold;">测试</a>是否是这个原因。</p>
<p></p>
<p>4, 其中一个或者两个表是MyISAM引擎的表,若想要使用外键约束,必须是InnoDB引擎,(实际上,如果两个表都是MyISAM 引擎的,这个错误根本不会发生,但也不会产生外键),你可以通过查询浏览器来设置表的引擎类型</p>
<p></p>
<p>5, 你可能设置了ON DELETE SET NULL, 但是相关的键的字段又设置成了NOTS NULL 值。你可能通过修改cascade 的属性值或者把字段属性设置成 allow null 来搞定这个bug.</p>
<p></p>
<p>6, 请确定你的Charset 和 Collate 选项在表级和字段级上的一致</p>
<p></p>
<p>7, 你可能设置为外键设置了一个默认值,如 default=0</p>
<p></p>
<p>8, 在这个关系里面,其中的一个字段是一个混合键值中的一个,它没有自己独立的索引,这时,你必须为它创建一个独立的索引。</p>
<p></p>
<p>9, ALTER 声明中有语法错误</p>
<p>本文来自CSDN博客,转载请标明出处:<a href="http://blog.csdn.net/herosen/archive/2009/04/26/4124626.aspx" target="_blank">http://blog.csdn.net/herosen/archive/2009/04/26/4124626.aspx</a></p>
<p>1、外键的引用类型不一样,主键是int外键是char <br>
<br>
2、找不到主表中 引用的列 <br>
<br>
3、主键和外键的字符编码不一致 <br>
<br>
4.还有要建立外键的话,要先建立索引。没有建立索引也会出错。 <br>
<br>
<br>
我的问题解决方案是在sql后面加上了如下句话,ok!成功导入脚本 <br>
<br>
ENGINE=MyISAM DEFAULT CHARSET=utf8;<br>
<br>
charset对应的换成你的主键表的字符集!</p>
   
</div>




<!-- Baidu Button BEGIN -->




<div class="bdsharebuttonbox tracking-ad bdshare-button-style0-16" style="float: right;" data-mod="popu_172" data-bd-bind="1497671329105">
<a href="#" class="bds_more" data-cmd="more" style="background-position:0 0 !important; background-image: url(http://bdimg.share.baidu.com/static/api/img/share/icons_0_16.png?v=d754dcc0.png) !important" target="_blank"></a>
<a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间" style="background-position:0 -52px !important" target="_blank"></a>
<a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博" style="background-position:0 -104px !important" target="_blank"></a>
<a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博" style="background-position:0 -260px !important" target="_blank"></a>
<a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网" style="background-position:0 -208px !important" target="_blank"></a>
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信" style="background-position:0 -1612px !important" target="_blank"></a>
</div>
<script>window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "1", "bdMiniList": false, "bdPic": "", "bdStyle": "0", "bdSize": "16" }, "share": {} }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];</script>
<!-- Baidu Button END -->

   

    
<!--172.16.140.14-->

<!-- Baidu Button BEGIN -->
<script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=1536434" src="http://bdimg.share.baidu.com/static/js/bds_s_v2.js?cdnversion=416020"></script>

<script type="text/javascript">
    document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
</script>
<!-- Baidu Button END -->



 


        <div id="digg" articleid="8773403">
            <dl id="btnDigg" class="digg digg_enable" onclick="btndigga();">
               
                 <dt>顶</dt>
                <dd>1</dd>
            </dl>
           
              
            <dl id="btnBury" class="digg digg_enable" onclick="btnburya();">
              
                  <dt>踩</dt>
                <dd>0</dd>               
            </dl>
            
        </div>
     <div class="tracking-ad" data-mod="popu_222"><a href="javascript:void(0);" target="_blank">&nbsp;</a>   </div>
    <div class="tracking-ad" data-mod="popu_223"> <a href="javascript:void(0);" target="_blank">&nbsp;</a></div>
    <script type="text/javascript">
                function btndigga() {
                    $(".tracking-ad[data-mod='popu_222'] a").click();
                }
                function btnburya() {
                    $(".tracking-ad[data-mod='popu_223'] a").click();
                }
            </script>

   <ul class="article_next_prev">
                <li class="prev_article"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shangyipian']);location.href='/xtm_rongbing/article/details/8772246';">上一篇</span><a href="/xtm_rongbing/article/details/8772246" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shangyipian'])">虚拟化系列-Citrix XenServer 6.1 虚拟机的管理</a></li>
                <li class="next_article"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_xiayipian']);location.href='/xtm_rongbing/article/details/8774516';">下一篇</span><a href="/xtm_rongbing/article/details/8774516" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_xiayipian'])">Hadoop NameNode结点不能启动</a></li>
    </ul>

    <div style="clear:both; height:10px;"></div>


            <div class="similar_article">
                    <h4></h4>
                    <div class="similar_c" style="margin:20px 0px 0px 0px">
                        <div class="similar_c_t">
                          &nbsp;&nbsp;相关文章推荐
                        </div>
                   
                        <div class="similar_wrap tracking-ad" data-mod="popu_36" style="max-height:195px;">                       
                            <ul class="similar_list fl">    
                                   <li>
                                       <em>•</em>
                                       <a href="http://blog.csdn.net/u012934942/article/details/46735901" title="Can't create table './store/#sql-b2c_1a.frm' (errno: 150)解决方法" strategy="" target="_blank" style="width: 290px;">Can't create table './store/#sql-b2c_1a.frm' (errno: 150)解决方法</a>
                                   </li>
                                   <li>
                                       <em>•</em>
                                       <a href="http://steven-walker.iteye.com/blog/2195394" title="ERROR 1005 (HY000): Can't create table '.\day17\employee.frm' (errno: 150)" strategy="" target="_blank" style="width: 290px;">ERROR 1005 (HY000): Can't create table '.\day17\employee.frm' (errno: 150)</a>
                                   </li>
                                   <li>
                                       <em>•</em>
                                       <a href="http://saiyaren.iteye.com/blog/1946501" title="java web 开发问题总结4  原创-胡志广" strategy="" target="_blank" style="width: 290px;">java web 开发问题总结4  原创-胡志广</a>
                                   </li>
                                   <li>
                                       <em>•</em>
                                       <a href="http://blog.csdn.net/shijiedemuguang/article/details/8026020" title="mysql [Err] 1005 - Can't create table '.\ \#sql-b34_61.frm' (errno: 150)" strategy="" target="_blank" style="width: 290px;">mysql [Err] 1005 - Can't create table '.\ \#sql-b34_61.frm' (errno: 150)</a>
                                   </li>
                                   <li>
                                       <em>•</em>
                                       <a href="http://xingqinstar.iteye.com/blog/1978660" title="常用技术开发网站记录(firefox版)" strategy="" target="_blank" style="width: 290px;">常用技术开发网站记录(firefox版)</a>
                                   </li>
                            </ul>
                              <ul class="similar_list fr">      
                                   <li>
                                       <em>•</em>
                                       <a href="http://blog.csdn.net/cctvbt/article/details/20622075" title="(转)Can't create table '.\***\#sql-ae4_34.frm' (errno: 150)" strategy="" target="_blank" style="width: 290px;">(转)Can't create table '.\***\#sql-ae4_34.frm' (errno: 150)</a>
                                   </li>
                                   <li>
                                       <em>•</em>
                                       <a href="http://koda.iteye.com/blog/678997" title="Mysql 的ERROR 1005 (HY000): Can't create table 'xxx' (errno: 150)" strategy="" target="_blank" style="width: 290px;">Mysql 的ERROR 1005 (HY000): Can't create table 'xxx' (errno: 150)</a>
                                   </li>
                                   <li>
                                       <em>•</em>
                                       <a href="http://blog.csdn.net/TryAgainToGet/article/details/59077713" title="ERROR 1005: Can't create table (errno: 121)" strategy="" target="_blank" style="width: 290px;">ERROR 1005: Can't create table (errno: 121)</a>
                                   </li>
                                   <li>
                                       <em>•</em>
                                       <a href="http://sjk2013.iteye.com/blog/1878187" title="MY SQL 创建带有外键的表失败的解决办法 [Err] 1005 - Can't create table 'xx' (errno: 150)" strategy="" target="_blank" style="width: 290px;">MY SQL 创建带有外键的表失败的解决办法 [Err] 1005 - Can't create table 'xx' (errno: 150)</a>
                                   </li>
                                   <li>
                                       <em>•</em>
                                       <a href="http://blog.csdn.net/FRuler/article/details/41854417" title="mysql:ERROR 1005 (HY000): Can't create table 'company.#sql-45d5_9' (errno: 150)" strategy="" target="_blank" style="width: 290px;">mysql:ERROR 1005 (HY000): Can't create table 'company.#sql-45d5_9' (errno: 150)</a>
                                   </li>
                            </ul>
                        </div>
                    </div>
                </div>   
      
</div>
阅读全文
0 0
原创粉丝点击