美文网首页
MySQL:ERROR 1286 (42000): Unknow

MySQL:ERROR 1286 (42000): Unknow

作者: 重庆八怪 | 来源:发表于2020-05-20 10:58 被阅读0次

    一、错误演示

    如下:

    root@localhost:test:09:49:03>create table ttt(id int) engine=myisam ;
    ERROR 1286 (42000): Unknown storage engine 'MyISAM'
    

    二、相关参数

    • enforce_storage_engine:建表进行引擎检查,是否满足设置的引擎值。
    • sql_mode(NO_ENGINE_SUBSTITUTION):根据前面的检查值进行综合判断,如果设置了NO_ENGINE_SUBSTITUTION则进行报错,如果没有设置则进行,且将新建表的引擎转为enforce_storage_engine设置的引擎。

    我们环境中设置enforce_storage_engine为Innodb,sql_mode中设置了NO_ENGINE_SUBSTITUTION。

    三、相关函数

    • check_engine
    • ->ha_enforce_handlerton

    部分逻辑如下:

    1. 根据ha_enforce_handlerton函数进行引擎检查,主要检查enforce_storage_engine参数设置的值是否为已知的引擎。否则报错 Unknown storage engine ,返回值为enforce_storage_engine指定的引擎(比如Innodb)。
    2. 根据上面的返回值进行判断
    • 如果建表指定的引擎(比如这里的MyISAM)和enforce_storage_engine设置的引擎(比如这里的Innodb)不同,同时sql_mode设置了NO_ENGINE_SUBSTITUTION。则报错ERROR 1286 (42000): Unknown storage engine 'MyISAM',这也是当前的报错。
    • 如果没有设置sql_mode NO_ENGINE_SUBSTITUTION,那么使用enforce_storage_engine指定的值代替建表语句的指定的引擎值(比如用Innodb代替MyISAM),同时报出警告,ER_WARN_USING_OTHER_HANDLER,输出为新的引擎值。

    四、修改

    注销掉enforce_storage_engine参数即可。

    五、栈

    #0  check_engine (thd=0x7fffe400a8a0, db_name=0x7fffe40108f0 "test", table_name=0x7fffe4010328 "ttt", create_info=0x7fffe8ecd890, alter_info=0x7fffe8ecd300)
        at /cdh/mysqldebug/percona-server-5.7.29-32/sql/sql_table.cc:11318
    #1  0x000000000155d81e in create_table_impl (thd=0x7fffe400a8a0, db=0x7fffe40108f0 "test", table_name=0x7fffe4010328 "ttt", error_table_name=0x7fffe4010328 "ttt", 
        path=0x7fffe8eccf60 "./test/ttt", create_info=0x7fffe8ecd890, alter_info=0x7fffe8ecd300, internal_tmp_table=false, select_field_count=0, no_ha_table=false, is_trans=0x7fffe8ecd1ee, 
        key_info=0x7fffe8ecd170, key_count=0x7fffe8ecd16c) at /cdh/mysqldebug/percona-server-5.7.29-32/sql/sql_table.cc:5138
    #2  0x000000000155f352 in mysql_create_table_no_lock (thd=0x7fffe400a8a0, db=0x7fffe40108f0 "test", table_name=0x7fffe4010328 "ttt", create_info=0x7fffe8ecd890, alter_info=0x7fffe8ecd300, 
        select_field_count=0, is_trans=0x7fffe8ecd1ee) at /cdh/mysqldebug/percona-server-5.7.29-32/sql/sql_table.cc:5753
    #3  0x000000000155f47a in mysql_create_table (thd=0x7fffe400a8a0, create_table=0x7fffe4010368, create_info=0x7fffe8ecd890, alter_info=0x7fffe8ecd300)
        at /cdh/mysqldebug/percona-server-5.7.29-32/sql/sql_table.cc:5801
    #4  0x00000000014cc36d in mysql_execute_command (thd=0x7fffe400a8a0, first_level=true) at /cdh/mysqldebug/percona-server-5.7.29-32/sql/sql_parse.cc:3510
    #5  0x00000000014d2e1b in mysql_parse (thd=0x7fffe400a8a0, parser_state=0x7fffe8ece4a0, update_userstat=false) at /cdh/mysqldebug/percona-server-5.7.29-32/sql/sql_parse.cc:5927
    #6  0x00000000014c7a55 in dispatch_command (thd=0x7fffe400a8a0, com_data=0x7fffe8ecec90, command=COM_QUERY) at /cdh/mysqldebug/percona-server-5.7.29-32/sql/sql_parse.cc:1539
    #7  0x00000000014c688a in do_command (thd=0x7fffe400a8a0) at /cdh/mysqldebug/percona-server-5.7.29-32/sql/sql_parse.cc:1060
    #8  0x00000000015fab28 in handle_connection (arg=0x3c4f150) at /cdh/mysqldebug/percona-server-5.7.29-32/sql/conn_handler/connection_handler_per_thread.cc:325
    #9  0x00000000018cad34 in pfs_spawn_thread (arg=0x3c568b0) at /cdh/mysqldebug/percona-server-5.7.29-32/storage/perfschema/pfs.cc:2198
    #10 0x00007ffff7bc6e65 in start_thread () from /lib64/libpthread.so.0
    #11 0x00007ffff5fa088d in clone () from /lib64/libc.so.6
    

    深入理解MySQL主从原理:https://www.jianshu.com/nb/43148932](https://www.jianshu.com/nb/43148932
    个人微信:gaopp_22389860

    相关文章

      网友评论

          本文标题:MySQL:ERROR 1286 (42000): Unknow

          本文链接:https://www.haomeiwen.com/subject/sudgohtx.html