mysql 默认的数据库引擎是MyISAM,不支持事务和外键,也可使用支持事务和外键的InnoDB。
查看当前数据库的所支持的数据库引擎以及默认数据库引擎:
我服务器环境系统为:centos5.3 mysql版本为:5.0.45
mysql> show engines;
+————+———-+——————————————————- ———+
| Engine | Support | Comment |
+————+———-+——————————————————- ———+
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tab les |
| InnoDB | DISABLED | Supports transactions, row-level locking, and foreign keys |
| BerkeleyDB | DISABLED | Supports transactions and page-level locking |
| BLACKHOLE | NO | /dev/null storage engine (anything you write to it dis appears) |
| EXAMPLE | NO | Example storage engine |
| ARCHIVE | NO | Archive storage engine |
| CSV | NO | CSV storage engine |
| ndbcluster | NO | Clustered, fault-tolerant, memory-based tables |
| FEDERATED | NO | Federated MySQL storage engine |
| MRG_MYISAM | YES | Collection of identical MyISAM tables |
| ISAM | NO | Obsolete storage engine |
+————+———-+——————————————————- ———+
12 rows in set (0.00 sec)
mysql>
通过上面我们可以发现,默认的数据库引擎是MyISAM ,在support中,显示为YES的为支持,NO为不支持,DEFAULT为默认,DISABLED为关闭,InooDB可以在my.cnf中配置开启:
注释掉my.cnf配置文件中“skip-innodb ”部分,保存重启服务。
再次查看,DISABLED就显示为YES了。
default-storage-engine=InnoDB
重启mysqld,再次show engines 确认。
数据库引擎默认就更改为InnoDB。
在windows环境中,数据库默认引擎为InnoDB,也可以通过修改my.ini 来定义默认引擎。方法一样。
PS:
在linux中的my.cnf配置文件中有这么一段:
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql/
#innodb_log_arch_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 – 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
使用InnoDB引擎的建议取消注释,以优化数据库性能。
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/826.html