By default, when we create table in MySQL, it will be using MyISAM, but when we need to create table in more advance use, like need to make foreign key, we have to use such a InnoDB as it storage engine. Some article said that we can simply change the engine with just alter the table like :

ALTER TABLE tableName ENGINE = InnoDB;

But I don’t know why its not working for me, so i tried to find another solution and solve it with set the table engine from the start like :

CREATE TABLE t (i INT) ENGINE = INNODB;

To make it work, first you must make sure the InnoDB storage engine is enable in my.cnf (your MySQL configuration) with simply comment skip InnoDB and uncomment the rest like this :

#skip-innodb
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = C:/xampp/mysql/data/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = C:/xampp/mysql/data/
innodb_log_arch_dir = C:/xampp/mysql/data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
set-variable = innodb_buffer_pool_size=16M
set-variable = innodb_additional_mem_pool_size=2M
# Set .._log_file_size to 25 % of buffer pool size
set-variable = innodb_log_file_size=5M
set-variable = innodb_log_buffer_size=8M
innodb_flush_log_at_trx_commit=1
set-variable = innodb_lock_wait_timeout=50 

After that, save it, restart the MySQL service and then create the table with InnoDB as the engine like query above. Simple isn’t? Hope the post help your problem.šŸ˜‰

For info about my newest post :