In general, MySQL will provide a variety of storage engines by default, which can be viewed through the following:
1) Check to see if MySQL has the InnoDB plugin installed.
The following command results indicate that the InnoDB plugin has been installed.
mysql> show plugins;+------------+--------+----------------+---------+--- ------+| Name | Status | Type | Library | License |+------------+--------+----------------+---------+---------+| Binlog | ACTIVE | STORAGE ENGINE | NULL | GPL | | Partition | ACTIVE | STORAGE ENGINE | NULL | GPL | | CSV | ACTIVE | STORAGE ENGINE | NULL | GPL | | MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL | | InnoDB | ACTIVE | STORAGE ENGINE | NULL | GPL | | MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL | | Mrg_myisam | ACTIVE | STORAGE ENGINE | NULL | GPL |+------------+--------+----------------+---------+---------+7 rows in Set (0.00 sec)
----------------------------------------------------------------------
If you find that the InnoDB plugin is not installed, you can install it by executing the following statement:
mysql> Install plugin innodb soname ' ha_innodb.so ';
----------------------------------------------------------------------
2) See what storage engines MySQL has now provided:
Mysql> Show engines;+------------+---------+------------------------------------------------------------+---- ----------+------+------------+| Engine | Support | Comment | Transactions | XA | savepoints |+------------+---------+------------------------------------------------------------+--------------+ ------+------------+| Mrg_myisam | YES | Collection of identical MyISAM tables | NO | NO | NO | | CSV | YES | CSV Storage Engine | NO | NO | NO | | MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO | | InnoDB | YES | Supports transactions, Row-level locking, and foreign keys | YES | YES | YES | | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |+------------+---------+------------------------------------------------------------+--------------+------+------------+5 rows in Set (0.00 sec)
3) View MySQL's current default storage engine:
Mysql> Show variables like '%storage_engine% '; +----------------+--------+| Variable_name | Value |+----------------+--------+| storage_engine | MyISAM |+----------------+--------+1 row in Set (0.00 sec)
4) Look at what engine the table uses (after the parameter engine in the display result, the storage engine that the table is currently using):
Mysql> Show create table table name;
Mysql> Show CREATE TABLE wx_share_log;+--------------+--------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -----------------------------+| Table | Create Table |+--------------+------------------------------------------ --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------+| Wx_share_log | CREATE TABLE ' Wx_share_log ' (' id ' int (one) not null auto_increment COMMENT ' share log increment id ', ' reference_id ' int (one) ' NOT null C Omment ' recommended broker ID ', ' create_time ' datetime not NULL COMMENT ' creation time ', PRIMARY KEY (' id ')) engine=myisam auto_increment=13 D Efault Charset=utf8 |+--------------+------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -------------------+1 Row in Set (0.00 sec)
5) How to convert the MyISAM library into the InnoDB engine format:
Replace the Engine=myisam with the ENGINE=INNODB in the backed-up xxx.sql file.
You can import it again.
6) The command to convert the table:
mysql> ALTER TABLE name ENGINE=INNODB;
As you can see above, the storage engine used by native MySQL is the default Myisan, and the storage engine must be changed to InnoDB because of business needs.
The operation record is as follows:
1) Turn off MySQL in safe mode
[Email protected] mysql5.1.57]# mysqladmin-uroot-p shutdown
Enter Password:
[[email protected] mysql5.1.57]# ps-ef|grep MySQL
2) Backup my.cnf
[email protected] mysql5.1.57]# CP my.cnf My.cnf.old
3) Modify the MY.CNF configuration file
[Email protected] mysql5.1.57]# vim my.cnf
.....
[Mysqld] //Add the following line in this configuration area to specify the storage engine as InnoDB
Default-storage-engine = InnoDB
4) Delete the ib_logfile0,ib_logfile1 in the/mysql/data directory. Delete or cut to a line elsewhere.
[Email protected] var]# MV Ib_logfile0 ib_logfile1/tmp/back/
5) Start MySQL, log in to MySQL to verify that the storage engine has switched
[Email protected] var]#/data/app/mysql5.1.57/bin/mysqld_safe--DEFAULTS-FILE=/DATA/APP/MYSQL5.1.57/MY.CNF &
Mysql> Show variables like '%storage_engine% '; +----------------+--------+| Variable_name | Value |+----------------+--------+| storage_engine | InnoDB |+----------------+--------+1 row in Set (0.00 sec)
MySQL replacement MyISAM Storage engine operation record for InnoDB