以前,在创build的每个数据库上,我使用:
mysql -u root -p CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_bin; GRANT ALL ON dbname.* TO 'dbuser'@'localhost';
然后在不考虑MyISAM或InnoDB的情况下使用数据库
如何知道数据库使用的存储引擎?
你可以像这样检查每个表格:
USE <database>; SHOW TABLE STATUS\G
你会得到这样的结果:
root@localhost/database> show table status\G *************************** 1. row *************************** Name: tablename Engine: MyISAM Version: 10 Row_format: Fixed Rows: 101 Avg_row_length: 70 Data_length: 7070 Max_data_length: 19703248369745919 Index_length: 2048 Data_free: 0 Auto_increment: 1004 Create_time: 2009-12-07 20:15:53 Update_time: 2010-11-10 21:55:01 Check_time: NULL Collation: latin1_swedish_ci Checksum: NULL Create_options: Comment:
使用'show engine'命令查看活动的默认引擎
在my.cnf文件的[mysqld]部分添加default-storage-engine = InnoDB,使默认引擎处于活动状态。
使用'show create table table_name'命令查看表中的默认引擎。
该查询列出了MySQL中的所有InnoDB表及其数据库:
SELECT table_name, table_schema FROM information_schema.tables WHERE engine = 'InnoDB';
您还可以列出所有表格及其存储引擎:
SELECT table_name, table_schema, engine FROM information_schema.tables;
获取特定表的引擎名称
use <database_name> show table status like '<table_name>';
改变引擎
alter table <table_name> engine <engine_name>;