实验环境如下:
OS: CentOS 5.8 Final
MySQL Version:5.5.19
脚本内容如下:
点击(此处)折叠或打开
[root@dbmaster ~]# mysql -h292.168.25.121 -utest -ptest
(test@192.168.25.121) [(none)] create database new;
Query OK, 1 row affected (0.01 sec)
(test@192.168.25.121) [(none)] show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| 361 |
| mysql |
| new |
| performance_schema |
| test |
+--------------------+
6 rows in set (0.00 sec)
[root@dbmaster ~]# mysql -h292.168.25.121 -utest -ptest new < 361.sql
(test@192.168.25.121) [(none)] use new;
Database changed
(test@192.168.25.121) [new] show tables;
+---------------------------+
| Tables_in_new |
+---------------------------+
| ad_magazine_content |
| ad_news_letter |
| conf_app |
| ip_province |
| ip_records |
| order_action |
| order_delivery |
| order_goods |
................................
(test@192.168.25.121) [information_schema] select TABLE_NAME,ENGINE from TABLES where TABLE_SCHEMA='new' and ENGINE='MyISAM';
+--------------------------+--------+
| TABLE_NAME | ENGINE |
+--------------------------+--------+
| ad_news_letter | MyISAM |
| conf_app | MyISAM |
| product_lib_attr_group | MyISAM |
| product_lib_brand | MyISAM |
| product_lib_ccard | MyISAM |
| product_lib_color | MyISAM |
| product_lib_fashion | MyISAM |
| product_lib_material | MyISAM |
| product_lib_season | MyISAM |
| product_lib_series | MyISAM |
| product_lib_size | MyISAM |
| product_lib_size_compare | MyISAM |
| product_lib_temperature | MyISAM |
| product_lib_type | MyISAM |
| product_lib_virtual_cat | MyISAM |
| req_conf_app | MyISAM |
| shop_keywords_details | MyISAM |
| system_api_user | MyISAM |
| system_payment | MyISAM |
| system_region | MyISAM |
| system_shop_dist | MyISAM |
| user_show_order | MyISAM |
+--------------------------+--------+
22 rows in set (0.02 sec)
[root@dbmaster scripts]# bash ChangeStorageEngine.sh
Starting convert table ad_news_letter......
Starting convert table conf_app......
Starting convert table product_lib_attr_group......
Starting convert table product_lib_brand......
Starting convert table product_lib_ccard......
Starting convert table product_lib_color......
Starting convert table product_lib_fashion......
Starting convert table product_lib_material......
Starting convert table product_lib_season......
Starting convert table product_lib_series......
Starting convert table product_lib_size......
Starting convert table product_lib_size_compare......
Starting convert table product_lib_temperature......
Starting convert table product_lib_type......
...............................
(test@192.168.25.121) [information_schema] select TABLE_NAME,ENGINE from TABLES where TABLE_SCHEMA='new' and ENGINE='MyISAM';
Empty set (0.01 sec)
[root@dbmaster scripts]# cat con_table.log
Convert table ad_news_letter ended.
Convert table conf_app ended.
Convert table product_lib_attr_group ended.
Convert table product_lib_brand ended.
Convert table product_lib_ccard ended.
Convert table product_lib_color ended.
Convert table product_lib_fashion ended.
Convert table product_lib_material ended.
Convert table product_lib_season ended.
Convert table product_lib_series ended.
Convert table product_lib_size ended.
Convert table product_lib_size_compare ended.
Convert table product_lib_temperature ended.
Convert table product_lib_type ended.
Convert table product_lib_virtual_cat ended.
Convert table req_conf_app ended.
Convert table shop_keywords_details ended.
Convert table system_api_user ended.
Convert table system_payment ended.
Convert table system_region ended.
Convert table system_shop_dist ended.
Convert table user_show_order ended.
###################################
有些表在转换的时候由于字符集,字段长度,外键约束等原因会出现一些问题,如下
点击(此处)折叠或打开
到此,相信大家对“MySQL怎么批量修改存储引擎”有了更深的了解,不妨来实际操作一番吧!这里是天达云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!