0

mysql更改引擎(InnoDB,MyISAM)

Posted in MySQL at 七月 2nd, 2010 / No Comments »

作者:wasw100
网址:http://www.wasw100.com/database/mysql_engine_innodb_myisam.html

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

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

数据库支持的引擎和默认数据库引擎代码 复制代码
  • show engines;  
  • show engines;

     

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

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

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

    Mysql代码 复制代码
  • –建表的时候指定   
  • create table mytbl(   
  •     id int primary key,   
  •     name varchar(50)   
  • )type=MyISAM;   
  •   
  • –建完表后修改   
  • alter table mytbl2 type = InnoDB;   
  •   
  •   
  • –查看修改结果(mytest为表所在的database名字)   
  • show table status from mytest;  
  • --建表的时候指定
    create table mytbl(
    	id int primary key,
    	name varchar(50)
    )type=MyISAM;
    
    --建完表后修改
    alter table mytbl2 type = InnoDB;
    
    --查看修改结果(mytest为表所在的database名字)
    show table status from mytest;
    Published in MySQL

    No Responses to “mysql更改引擎(InnoDB,MyISAM)”

    Leave a Reply

    请输入算式结果(看不清请点击图片)
    (必须)