---
title: "mysql更改引擎(InnoDB,MyISAM)"
author: "siser344"
date: "2010-07-01T16:29:14Z"
tags: []
categories: ["数据库"]
slug: "mysql-innodb-myisam"
draft: false
lastmod: "2010-07-01T16:29:14Z"
id: 703654
url: "https://siser344.iteye.com/blog/703654"
---

mysql默认的数据库引擎是MyISAM，不支持事务和外键，也可使用支持事务和外键的InnoDB。

**查看当前数据库的所支持的数据库引擎以及默认数据库引擎**

```
show engines;  
```

 

**更改方式1：修改配置文件my.ini**

我将my-small.ini另存为my.ini，在\[mysqld]最后添加为上default-storage-engine=InnoDB，重启服务，数据库默认的引擎修改为InnoDB

**更改方式2：在建表的时候指定或者建完表修改**

```
--建表的时候指定   
create table mytbl(   
    id int primary key,   
    name varchar(50)   
)type=MyISAM;   
  
--建完表后修改   
alter table mytbl2 type = InnoDB;   
  
  
--查看修改结果（mytest为表所在的database名字）   
show table status from mytest;  
```