{"id":20633,"date":"2020-11-30T04:23:10","date_gmt":"2020-11-29T20:23:10","guid":{"rendered":"https:\/\/web.mwwsb.com.my\/pjci\/?post_type=kb&#038;p=20633"},"modified":"2023-01-18T10:58:08","modified_gmt":"2023-01-18T02:58:08","slug":"working-with-mysql-database-engines","status":"publish","type":"kb","link":"https:\/\/www.casbay.com\/guide\/kb\/working-with-mysql-database-engines","title":{"rendered":"Working with MySQL database engines"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"20633\" class=\"elementor elementor-20633\" data-elementor-post-type=\"kb\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-9bffb3d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"9bffb3d\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-c7f642f\" data-id=\"c7f642f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-52c3cec elementor-widget elementor-widget-heading\" data-id=\"52c3cec\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-medium\">Working with MySQL database engines<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5b28f70 elementor-widget elementor-widget-heading\" data-id=\"5b28f70\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">MySQL Database Engines<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b5b8f4a elementor-widget elementor-widget-text-editor\" data-id=\"b5b8f4a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Database engines provide underlying functionality for MySQL to work with and process data.<\/p><p>There are two most common and popular MySQL database engines: <strong>MyISAM<\/strong> and <strong>InnoDB<\/strong>. <strong>MyISAM<\/strong> is the default engine for MySQL (versions earlier than 5.5.5). It functions well in most scenarios and it is depending on your needs. There are some situations where another database engine, such as <strong>InnoDB<\/strong>, may be the better choice. For example, one of the differences between them is InnoDB supports transactions, whereas MyISAM does not. Besides, InnoDB provides support for foreign keys, whereas MyISAM does not.<\/p><p>Furthermore, you can complete control over how and when MySQL uses the various database engines when you have root access to your server. You can also change the default database engine, change the database engine of a specific table, and more.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6124c55 elementor-widget elementor-widget-heading\" data-id=\"6124c55\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-large\">Determining The Default Database Engine\n<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bbdc755 elementor-widget elementor-widget-text-editor\" data-id=\"bbdc755\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Firstly, type the following command at the <strong>mysql<\/strong>&gt; prompt:<\/p><p>SHOW ENGINES;<br \/>A list of supported engines appears, along with a brief description and the supported features for each engine. The default database engine is marked <strong>DEFAULT<\/strong> in the &#8220;Support&#8221; column.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fb10992 elementor-widget elementor-widget-heading\" data-id=\"fb10992\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-large\">Changing The Default Database Engine<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8fae602 elementor-widget elementor-widget-text-editor\" data-id=\"8fae602\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>You can change the default database engine for your MySQL installation. After you do this, all new tables that you create will use the new database engine (unless you explicitly set the engine during table creation).<\/p><p>To change the default database engine, follow these steps:<\/p><ol><li>Use your preferred text editor to open the\u00a0<em>my.cnf<\/em>\u00a0file on your server. The location of the\u00a0<em>my.cnf<\/em>\u00a0file depends on your Linux distribution:<ul><li>On CentOS and Fedora, the\u00a0<em>my.cnf<\/em>\u00a0file is located in the\u00a0<strong>\/etc<\/strong>\u00a0directory.<\/li><li>On Debian and Ubuntu, the\u00a0<em>my.cnf<\/em>\u00a0file is located in the\u00a0<strong>\/etc\/mysql<\/strong>\u00a0directory.<\/li><\/ul><\/li><li>In the\u00a0<em>my.cnf<\/em>\u00a0file, locate the\u00a0<strong>[mysqld]<\/strong>\u00a0section.<\/li><li>Add or modify the following line in the\u00a0<strong>[mysqld]<\/strong>\u00a0section. Replace\u00a0<em>ENGINE<\/em>\u00a0with the name of the engine that you want to use as the default:<\/li><\/ol><pre class=\"code\">default-storage-engine=<em>ENGINE<\/em><\/pre><div class=\"important\"><p>If you are enabling the InnoDB database engine, depending on your Linux distribution you may have to disable the following line in the\u00a0<em>my.cnf<\/em>\u00a0file:<\/p><pre class=\"code\">skip-innodb<\/pre><p>To do this, just add a pound sign (<strong>#<\/strong>) to the beginning of the line, as follows:<\/p><pre class=\"code\">#skip-innodb<\/pre><ol><li>Save the changes to the\u00a0<em>my.cnf<\/em>\u00a0file, and then exit the text editor.<\/li><li>Restart the MySQL server using the appropriate command for your Linux distribution:<ul><li>For CentOS and Fedora, type:<br \/><pre class=\"command\">service mysqld restart<\/pre><\/li><li>For Debian and Ubuntu, type:<br \/><pre class=\"command\">service mysql restart<\/pre><\/li><\/ul><\/li><li>To confirm the new default database engine, use the\u00a0<strong>SHOW ENGINES<\/strong> SQL statement as described in the &#8220;Determining the default database engine&#8221; section.<\/li><\/ol><\/div>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-179b233 elementor-widget elementor-widget-heading\" data-id=\"179b233\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-large\">Determining A Table's Current Database Engine<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-93b0fd0 elementor-widget elementor-widget-text-editor\" data-id=\"93b0fd0\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"important\"><p>To determine which engine a database table is currently using, type the following command at the\u00a0<strong>mysql&gt;<\/strong> prompt. Replace the\u00a0<em>database<\/em>\u00a0with the name of the database that you want to check:<\/p><pre class=\"command\">SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '<em>database<\/em>';<\/pre><p>This command displays a list of every table in the database, along with the engine each table is using.<\/p><\/div>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5944396 elementor-widget elementor-widget-heading\" data-id=\"5944396\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-large\">Changing A Table's Database Engine<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c6f97ac elementor-widget elementor-widget-text-editor\" data-id=\"c6f97ac\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"important\"><p>You can change the database engine for a table that already exists. For example, the following SQL statement shows how to modify a table named\u00a0<em>myTable<\/em>\u00a0to use the InnoDB engine:<\/p><pre class=\"command\">ALTER TABLE myTable ENGINE = InnoDB;<\/pre><\/div>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c55b26a elementor-widget elementor-widget-heading\" data-id=\"c55b26a\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-large\">Creating A New Table With A Specific Database Engine<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-848fdc6 elementor-widget elementor-widget-text-editor\" data-id=\"848fdc6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"important\"><p>When you create a table in a database, you can explicitly set its database engine (otherwise, MySQL uses the default database engine during table creation). For example, the following SQL statement shows how to create a table named\u00a0<em>myTable<\/em>\u00a0that uses the MyISAM database engine:<\/p><pre class=\"command\">CREATE TABLE myTable (\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 id INT NOT NULL AUTO_INCREMENT,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PRIMARY KEY (id),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 data VARCHAR(20) NOT NULL\n) ENGINE MyISAM;<\/pre><p>Similarly, to create a table that uses the InnoDB database engine, you could use the following SQL statement:<\/p><pre class=\"command\">CREATE TABLE myTable (\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 id INT NOT NULL AUTO_INCREMENT,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PRIMARY KEY (id),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 data VARCHAR(20) NOT NULL\n) ENGINE InnoDB;<\/pre><\/div>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-0320d9b elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"0320d9b\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d352e8c\" data-id=\"d352e8c\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-de4ed77 elementor-widget elementor-widget-text-editor\" data-id=\"de4ed77\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>If you find this article helpful, you can learn more on the topic <a href=\"https:\/\/www.casbay.com\/guide\/kb\/working-with-mysql-database-engines\">Database (MS SQL &amp; MySQL)<\/a>.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Working with MySQL database engines MySQL Database Engines Database engines provide underlying functionality for MySQL to work with and process data. There are two most common and popular MySQL database engines: MyISAM and InnoDB. MyISAM is the default engine for MySQL (versions earlier than 5.5.5). It functions well in most scenarios and it is depending [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"page-builder","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}}},"kbtopic":[60],"kbtag":[106],"mkb_version":[],"_links":{"self":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/20633"}],"collection":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/comments?post=20633"}],"version-history":[{"count":2,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/20633\/revisions"}],"predecessor-version":[{"id":38200,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/20633\/revisions\/38200"}],"wp:attachment":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/media?parent=20633"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=20633"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtag?post=20633"},{"taxonomy":"mkb_version","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/mkb_version?post=20633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}