MySQL Tutorial
MySQL Installation and Configuration
MySQL Database Operations
Database Design
MySQL Data Types
MySQL Storage Engines
MySQL Basic Operations of Tables
MySQL Constraints
MySQL Operators
MySQL Function
MySQL Manipulate Table Data
MySQL View
MySQL Indexes
MySQL Stored Procedure
MySQL Trigger
MySQL Transactions
MySQL Character Set
MySQL User Management
MySQL Database Backup and Recovery
MySQL Log
MySQL Performance Optimization
MySQL supports multiple storage engines, each with its own advantages and disadvantages. The most commonly used storage engine in MySQL is InnoDB, as it supports transactions, row-level locking, and foreign keys.
You can check the default storage engine of your MySQL server by running the following SQL command:
SHOW VARIABLES LIKE 'default_storage_engine';
This will return the current default storage engine.
If you want to change the default storage engine, you can do so by modifying the MySQL configuration file. The steps vary slightly depending on your operating system.
For Unix and Linux Systems:
Open your MySQL configuration file. The exact location of this file can vary, but common locations include /etc/my.cnf
or /etc/mysql/my.cnf
.
Look for a section labeled [mysqld]
. Under this section, you can specify the default storage engine by adding or modifying the following line:
default-storage-engine = ENGINE_NAME
Replace ENGINE_NAME
with the name of the storage engine you want to use (for example, innodb
).
Save the changes and close the file.
Restart your MySQL server for the changes to take effect. You can typically do this with a command like service mysql restart
or systemctl restart mysql
, depending on your specific system.
For Windows Systems:
Open your MySQL configuration file, usually named my.ini
, which is typically located in the MySQL installation directory.
Look for a section labeled [mysqld]
. Under this section, you can specify the default storage engine by adding or modifying the following line:
default-storage-engine=ENGINE_NAME
Replace ENGINE_NAME
with the name of the storage engine you want to use (for example, innodb
).
Save the changes and close the file.
Restart your MySQL service for the changes to take effect. You can do this through the services management console (services.msc
), or by using the net stop
and net start
commands from the command prompt.
Remember, changing the default storage engine will only affect new tables that are created. Existing tables will continue to use the storage engine they were created with.
View default storage engine in MySQL:
storage_engine
.SHOW VARIABLES LIKE 'storage_engine';
Check default storage engine for MySQL databases:
information_schema
.SELECT SCHEMA_NAME, DEFAULT_STORAGE_ENGINE FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = 'your_database_name';
How to find MySQL default storage engine:
information_schema
.SELECT @@default_storage_engine AS default_storage_engine;
Modify default storage engine in MySQL:
my.cnf
configuration file. Add or modify the default_storage_engine
parameter.-- Add to my.cnf [mysqld] default_storage_engine=InnoDB
Change default storage engine for MySQL tables:
CREATE TABLE my_table ( id INT PRIMARY KEY, name VARCHAR(255) ) ENGINE=MyISAM;
MySQL set default storage engine command:
SET
command.SET default_storage_engine=InnoDB;
View and update default storage engine in MySQL:
default_storage_engine
variable.-- View default storage engine SHOW VARIABLES LIKE 'default_storage_engine'; -- Update default storage engine SET GLOBAL default_storage_engine=InnoDB;
Configure default storage engine for MySQL:
my.cnf
configuration file.-- Add to my.cnf [mysqld] default_storage_engine=MyISAM
MySQL show default storage engine:
SHOW
command to display the current default storage engine.SHOW VARIABLES LIKE 'default_storage_engine';
Setting default storage engine globally in MySQL:
my.cnf
configuration file.-- Add to my.cnf [mysqld] default_storage_engine=MEMORY