Search code examples
mysqllockinginnodb

MySQL returns "Can't create table because of lock error (errno: 147)"


When I'm trying to create various table for a project via an import sql, MySQL returns this error :

#1005 - Can't create table 'mybase.mytable' (errno: 147) 

Looking in Google for 147, I found that :

MySQL error code 147: Lock table is full; Restart program with a larger locktable

However, I don't know how to do that. What should I modify, and to what? (there are a lot of lock variables).

Here's a result of all my 'lock' variables :

innodb_autoinc_lock_mode          1
innodb_lock_wait_timeout          50
innodb_locks_unsafe_for_binlog    OFF
innodb_table_locks                ON
key_cache_block_size              1024
locked_in_memory                  OFF
max_write_lock_count              18446744073709551615
query_alloc_block_size            8192
query_cache_wlock_invalidate      OFF
range_alloc_block_size            4096
skip_external_locking             ON
table_lock_wait_timeout           50
transaction_alloc_block_size      8192

Solution

  • I finally found how to do it, I switched the innodb_table_locks to off before creating my tables, and then re-enabling it.

    SET innodb_table_locks = 0;
    
    // Create tables
    
    SET innodb_table_locks = 1;