Is there a command in terminal for finding out what storage engine my MySQL database is using?
7 Answers
This is available in a few places.
From the SHOW CREATE TABLE
output.
mysql> SHOW CREATE TABLE guestbook.Guestbook;
+-----------+-------------------------------------------+
| Table | Create Table |
+-----------+-------------------------------------------+
| Guestbook | CREATE TABLE `Guestbook` (
`NAME` varchar(128) NOT NULL DEFAULT '',
`MESSAGE` text NOT NULL,
`TIMESTAMP` varchar(24) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-----------+-------------------------------------------+
1 row in set (0.00 sec)
From information_schema
You may also find it in information_schema.TABLES
if you want to query the engines of multiple tables.
SELECT ENGINE
FROM information_schema.TABLES
WHERE
TABLE_NAME='yourtable'
AND TABLE_SCHEMA='yourdatabase';

- 1
- 1

- 267,341
- 46
- 444
- 390
-
`SHOW CREATE TABLE` is how I do it. – Marcus Adams May 02 '12 at 21:19
SHOW ENGINES;
return the engines your MySQL database support and tell you which is the default one if not otherwise specified at creation time.

- 243
- 1
- 3
- 9
A database on MySQL can use multiple storage engines, so you'll have to check per-table. Simplest is to do
show create table yourtable;
and see what the 'engine' line at the end of the DDL statement is. e.g. engine=InnoDB
, engine=MyISAM
, etc...
If you want to check all the tables in your DB:
select TABLE_NAME, ENGINE
from information_schema.TABLES
where TABLE_SCHEMA='yourdbname'

- 10,604
- 5
- 48
- 74

- 356,200
- 43
- 426
- 500
-
what if `engine` column for some tables is `InnoDB` and null for others? what does null mean in this case? – user1623521 Jun 22 '16 at 05:18
This is a longer solution but it can be useful if you want to learn something about information_schema
mysql> select table_name,engine from information_schema.tables where table_name
= 'table_name' and table_schema = 'db_name';

- 54,599
- 15
- 92
- 98
-
what if `engine` column for some tables is `InnoDB` and null for others? what does null mean in this case? – user1623521 Jun 22 '16 at 05:19
You can use this command:
mysql -u[user] -p -D[database] -e "show table status\G"| egrep "(Index|Data)_length" | awk 'BEGIN { rsum = 0 } { rsum += $2 } END { print rsum }'

- 727
- 13
- 28
mysql -u[user] -p -D[database] -e "show table status\G" | egrep "(Engine|Name)"
This will list all the tables and their corresponding engine. Good to get an overview of everything!
It's a modified answer from @yago-riveiro where he showed how to get the size of the tables, rather than the engines in use. Also, it's better to have an explanation on what a command does.

- 321
- 11
- 24