通過MySQL -uroot -p登錄到數(shù)據(jù)庫。
1.查看當前的引擎
mysql> show engines /G;mysql> show engines /G;ERROR 2006 (HY000): MySQL server has gone awayNo connection. Trying to reconnect...Connection id: 4Current database: *** NONE ****************************** 1. row *************************** Engine: PERFORMANCE_SCHEMA Support: YES Comment: Performance SchemaTransactions: NO XA: NO Savepoints: NO*************************** 2. row *************************** Engine: MRG_MYISAM Support: YES Comment: Collection of identical MyISAM tablesTransactions: NO XA: NO Savepoints: NO*************************** 3. row *************************** Engine: CSV Support: YES Comment: CSV storage engineTransactions: NO XA: NO Savepoints: NO*************************** 4. row *************************** Engine: BLACKHOLE Support: YES Comment: /dev/null storage engine (anything you write to it disappears)Transactions: NO XA: NO Savepoints: NO*************************** 5. row *************************** Engine: InnoDB Support: YES Comment: Supports transactions, row-level locking, and foreign keysTransactions: YES XA: YES Savepoints: YES*************************** 6. row *************************** Engine: MEMORY Support: YES Comment: Hash based, stored in memory, useful for temporary tablesTransactions: NO XA: NO Savepoints: NO*************************** 7. row *************************** Engine: ARCHIVE Support: YES Comment: Archive storage engineTransactions: NO XA: NO Savepoints: NO*************************** 8. row *************************** Engine: MyISAM Support: DEFAULT Comment: MyISAM storage engineTransactions: NO XA: NO Savepoints: NO*************************** 9. row *************************** Engine: FEDERATED Support: NO Comment: Federated MySQL storage engineTransactions: NULL XA: NULL Savepoints: NULL9 rows in set (0.00 sec)
2. 查看默認引擎
mysql> show variables like '%storage_engine%';
mysql> show variables like '%storage_engine%';+----------------------------------+--------+| Variable_name | Value |+----------------------------------+--------+| default_storage_engine | InnoDB || default_tmp_storage_engine | InnoDB || disabled_storage_engines | || internal_tmp_disk_storage_engine | InnoDB |+----------------------------------+--------+
通過上面我們可以發(fā)現(xiàn),默認的數(shù)據(jù)庫引擎是InnoDB
3.修改引擎
#vi /etc/my.cnf
在my.cnf中[mysqld] 部分添加代碼: default-storage-engine=MyISAM
重啟mysqld:service mysqld restart再次show engines 確認。 數(shù)據(jù)庫引擎默認就更改為MyISAM。
mysql> show variables like '%storage_engine%';+----------------------------------+--------+| Variable_name | Value |+----------------------------------+--------+| default_storage_engine | MyISAM || default_tmp_storage_engine | InnoDB || disabled_storage_engines | || internal_tmp_disk_storage_engine | InnoDB |+----------------------------------+--------+
4.設置表的存儲引擎
語法:
CREATE TABLE 表名( #省略代碼)ENGINE=存儲引擎;
示例:
CREATE TABLE `myisam` ( id INT(4))ENGINE=MyISAM;
在windows環(huán)境中,數(shù)據(jù)庫默認引擎為InnoDB,也可以通過修改my.ini 來定義默認引擎。方法一樣
新聞熱點
疑難解答
圖片精選