如何将mysql数据库中的MyISAM类型表更改为InnoDB类型的表

it2022-05-05  95

如何将mysql数据库中的MyISAM类型表更改为InnoDB类型的表

改单个表改多个表修改为InnoDB修改为MyISAM 批量修改mysql数据库字符集Mysql修改表、字段、库的字符集

改单个表

ALTER TABLE TABLENAME ENGINE=InnoDB; ALTER TABLE TABLENAME ENGINE=MyISAM;

改多个表

修改为InnoDB

SELECT CONCAT( 'ALTER TABLE ', TABLE_NAME, ' ENGINE=InnoDB;' ) FROM information_schema.tables WHERE table_schema = 'DBNAME' LIMIT 0 , 10000;  

修改为MyISAM

SELECT CONCAT( 'ALTER TABLE ', TABLE_NAME, ' ENGINE=MyISAM;' ) FROM information_schema.tables WHERE table_schema = 'DBNAME' LIMIT 0 , 10000;

使用说明:

将以上SQL语句中的 DBNAME 替换成需要修改的数据库名称。

执行SQL,这个时候还没有修改,只是给了一个查询结果。

将查询结果复制,去掉前后的引号,然后执行。

批量修改mysql数据库字符集

ALTER DATABASE DBNAME DEFAULT CHARACTER SET=‘utf8’;

mysql数据库表字段乱码,连接数据库时设置正确的编码即可

mysql_query(‘set names utf8’);

Mysql修改表、字段、库的字符集

ALTER DATABASE `zcqipa250` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `qipa250_articles` ENGINE=INNODB; ALTER TABLE `qipa250_articles_text` ENGINE=INNODB; ALTER TABLE `qipa250_authors` ENGINE=INNODB; ALTER TABLE `qipa250_comments` ENGINE=INNODB; ALTER TABLE `qipa250_comments_description` ENGINE=INNODB; ALTER TABLE `popular_searches` ENGINE=INNODB; ALTER TABLE `un_products_to_wishlists` ENGINE=INNODB; ALTER TABLE `un_wishlists` ENGINE=INNODB; ALTER TABLE `qipa250_articles` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `qipa250_articles_text` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `qipa250_authors` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `qipa250_comments` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `qipa250_comments_description` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `popular_searches` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `un_products_to_wishlists` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `un_wishlists` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

最新回复(0)