亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

??

一般批量修改MYSQL中某表的數(shù)據(jù)庫引擎可以利用官方工具mysql_convert_table_format來實現(xiàn), 這里指的是不使用其他工具僅用shell的方法來實現(xiàn)。(以下例子效果是將數(shù)據(jù)庫shop中所有引擎不為InnoDB的表修改為使用InnoDB引擎)[ 查看表引擎的語句:show create table tableName; ],其實核心關鍵點是這條語句:

alert table tableName engine=innodb;

下面開始修改:

備份數(shù)據(jù)庫

在命令行下運行得到備份SQL

mysqldump -uroot -p******** shop > shop20160505.sql

在命令行建立一個測試數(shù)據(jù)庫并導入SQL

mysql -uroot -p******** -e 'create database shop_to_innodb charset utf8';
mysql -uroot -p******** shop_to_innodb < shop20160505.sql

shell獲取需要更換表引擎

mysql -uroot -p******** -e "show table status from shop_to_innodb where Engine <> 'InnoDB' \G"|grep Name|awk '{print "alter table "$2" engine=innodb;";}' > mysql_change_to_innodb.txt

上面的語句在命令行中執(zhí)行得到 mysql_change_to_innodb.txt 文件(包含了shop_to_innodb庫中所有引擎不為InnoDB的改變語句)。

查看導出的修改語句

使用vim命令或者cat命令查看 mysql_change_to_innodb.txt 文件,檢查是否為自己要修改的內容。

alter table a engine=innodb;
alter table b engine=innodb;
alter table category engine=innodb;
alter table ecs_account_log engine=innodb;
alter table ecs_ad engine=innodb;
alter table ecs_ad_custom engine=innodb;
alter table ecs_ad_position engine=innodb;
alter table ecs_admin_action engine=innodb;
alter table ecs_admin_log engine=innodb;
alter table ecs_admin_message engine=innodb;
alter table ecs_admin_user engine=innodb;
alter table ecs_adsense engine=innodb;
alter table ecs_affiliate_log engine=innodb;
alter table ecs_agency engine=innodb;
alter table ecs_area_region engine=innodb;
alter table ecs_article engine=innodb;
alter table ecs_article_cat engine=innodb;
alter table ecs_attribute engine=innodb;
alter table ecs_auction_log engine=innodb;
alter table ecs_auto_manage engine=innodb;
alter table ecs_back_goods engine=innodb;
alter table ecs_back_order engine=innodb;
alter table ecs_bonus_type engine=innodb;
alter table ecs_booking_goods engine=innodb;
alter table ecs_brand engine=innodb;
alter table ecs_card engine=innodb;
alter table ecs_cart engine=innodb;
... ...

執(zhí)行修改語句

如果沒用問題我們可以接著執(zhí)行下面的語句。

mysql -uroot -p******** shop_to_innodb < mysql_change_to_innodb.txt

如果數(shù)據(jù)庫非常大可能要等一段時間


?? ??: ?? ??: