Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See what storage engine MySQL database uses via terminal

Is there a command in terminal for finding out what storage engine my MySQL database is using?

like image 889
NightHawk Avatar asked May 02 '12 21:05

NightHawk


People also ask

How do I know which storage engine is used in MySQL?

Issue the SHOW ENGINES statement to view the available MySQL storage engines. Look for DEFAULT in the SUPPORT column. mysql> SHOW ENGINES; Alternatively, query the INFORMATION_SCHEMA.

How do I know if I have MySQL InnoDB or MyISAM?

Simply check the value of the Engine column in the returned dataset to know which engine the table is using. Show activity on this post. SELECT ENGINE FROM INFORMATION_SCHEMA. TABLES WHERE TABLE_NAME='your_table_name' AND TABLE_SCHEMA='your_database_name'; -- or use TABLE_SCHEMA=DATABASE() if you have a default one.

How do I know which database MySQL is using?

mysql> show databases; Here is the output that displays all the databases. As you can see above, we have both databases, and we can get the current database name with the help of DATABASE() method.

How do I check my engine storage?

Add default-storage-engine=InnoDB in [mysqld] section of the my. cnf file for the default engine to be active. Use the 'show create table table_name' command to view default engine in the table.


2 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';
like image 129
Michael Berkowski Avatar answered Nov 12 '22 22:11

Michael Berkowski


SHOW ENGINES;

return the engines your MySQL database support and tell you which is the default one if not otherwise specified at creation time.

like image 40
Victor Avatar answered Nov 12 '22 20:11

Victor