如何更改mysql数据库引擎

linux下,mysql5,我安装时选择了不支持事务的安装,现在需要用到事务,但不能创建INNODB类型的表了,我应该怎么做,那里可以设置吗?

修改MySQL数据库引擎步骤如下
第一:修改my.ini,在[mysqld]下加上:
default-storage-engine=引擎名称
其中的等号后面是要指定的数据库引擎名称。
第二:用sql语句修改已经建成表的引擎:
alter table tableName type=InnoDB --type语法在4.X版本下存在
alter table tableName ENGINE=InnoDB --5.X下都改成engine=innodb

举例说明下面贴出我的my.ini文件供参考:
[mysqld] basedir=C:\Program Files\VertrigoServ\Mysql\ datadir=C:\Program Files\VertrigoServ\Mysql\data\ port =3306 key_buffer =64M max_allowed_packet =1M table_cache =128 sort_buffer_size =512K net_buffer_length =8K read_buffer_size =256K read_rnd_buffer_size =512K myisam_sort_buffer_size =68M default-storage-engine=INNODB [mysqldump] quick max_allowed_packet =116M [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates [isamchk] key_buffer =20M sort_buffer_size =20M read_buffer =62M write_buffer =62M [myisamchk] key_buffer =20M sort_buffer_size =20M read_buffer =62M write_buffer =62M [mysqlhotcopy] interactive-timeout
按照以上的代码提示操作,我们就能够成功地修改MySQL数据库引擎为INNODB了。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-02-28

请采用以下sql脚本:

--查询表状态

SHOW TABLE STATUS FROM sites WHERE NAME='site';  
SHOW TABLE STATUS FROM db_name WHERE NAME='table_name';  
 

--更改表的引擎
alter table table_name engine=innodb;  
alter table table_name engine=myisam;

如有疑问,及时沟通。

第2个回答  推荐于2017-11-26
CREATE TABLE 表名
(
字段……
) ENGINE=InnoDB
就可以了啊

如果还不行,就直接到MySQL目录里的my.ini文件中把default-storage-engine这一行改过来,把默认的存储引擎改为InnoDB,重启数据库服务器就行了。本回答被提问者采纳