MySQL database MyISAM storage engine to Innodb method
- 2020-06-19 11:51:27
- OfStack
When the mysql database storage engine is MyISAM, the data table may be locked in the case of large amount of traffic, which will cause the user to timeout when connecting to the website and return 502. In this case, the MySQL database MyISAM storage engine needs to be converted to Innodb.
The steps are as follows:
1. Export the table structure of CentOS database
Where the -ES13en parameter means that no data is exported, only the table structure is exported
centos_table. MyISAM in sql is INNODB
3. Create a new database centos_new and import the table structure
You can check that the table engine is INNODB via show table status.
4. Export data of centos
The -t parameter represents only the derivative data and does not guide the table structure
5. Import data to centos_new
The steps are as follows:
1. Export the table structure of CentOS database
mysqldump -d -uxxx -p centos > centos_table.sql
Where the -ES13en parameter means that no data is exported, only the table structure is exported
centos_table. MyISAM in sql is INNODB
sed -i 's/MyISAM/INNODB/g' centos_table.sql
3. Create a new database centos_new and import the table structure
mysql > create database centos_new;
mysql -uroot -p centos_new < centos_table.sql
You can check that the table engine is INNODB via show table status.
4. Export data of centos
mysqldump -t -uroot -p centos > centos_data.sql
The -t parameter represents only the derivative data and does not guide the table structure
5. Import data to centos_new
mysql -uroot -p centos_new < centos_data.sql