zoukankan      html  css  js  c++  java
  • mysql_convert_table_format 批量修改表引擎

    [root@server-mysql bin]# mysql_convert_table_format --help
    
     Conversion of a MySQL tables to other storage engines
    
     Usage: /usr/bin/mysql_convert_table_format database [table[ table ...]]
    1.
    If no tables has been specifed, all tables in the database will be converted.
    2.You can also
    use wildcards, ie "my%"
    The following options are available:
    -f, --force Continue even if there is some error. -?, --help Shows this help -e, --engine=ENGINE Converts tables to the given storage engine (Default: MYISAM) -h, --host=HOST Host name where the database server is located. (Default: localhost) -p, --password=PASSWORD Password for the current user. -P, --port=PORT TCP/IP port to connect to if host is not "localhost". -S, --socket=SOCKET Socket to connect with. -u, --user=USER User name to log into the SQL server. -v, --verbose This is a test specific option that is only used when debugging a test. Print more information about what is going on. -V, --version Shows the version of this program.
    convert.sh
    #!/bin/bash
    /usr/local/mysql56/bin
    echo 'Enter Host Name:' read HOSTNAME echo 'Enter User Name:' read USERNAME echo 'Enter Password:' read PASSWD echo 'Enter Socket Path:' read SOCKETPATH echo 'Enter Database Name:' read DBNAME echo 'Enter Table Name:' read TBNAME echo 'Enter Table Engine:' read TBTYPE

    /usr/local/mysql56/bin/mysql_convert_table_format --host=$HOSTNAME --user=$USERNAME --password=$PASSWD --socket=$SOCKETPATH --type=$TBTYPE $DBNAME $TBNAME --verbose

    mysql> select concat(table_schema,'.',table_name) as table_name ,engine from information_schema.tables where table_schema = 'test';
    +------------+--------+
    | table_name | engine |
    +------------+--------+
    | test.t     | InnoDB |
    | test.t1    | InnoDB |
    | test.t3    | InnoDB |
    | test.t4    | InnoDB |
    | test.t5    | InnoDB |
    +------------+--------+
    5 rows in set (0.01 sec)

    [root@server-mysql ~]# ./convert.sh
    ./convert.sh: line 3: /usr/local/mysql56/bin: is a directory
    Enter Host Name:
    localhost
    Enter User Name:
    root
    Enter Password:
    Aa@12345
    Enter Socket Path:
    /tmp/mysql.sock5
    Enter Database Name:
    test
    Enter Table Name:
    
    Enter Table Engine:
    MYISAM
    Warning: /usr/local/mysql56/bin/mysql_convert_table_format is deprecated and will be removed in a future version.
    Converting tables:
    converting t
    converting t1
    converting t3
    converting t4
    converting t5
    mysql> select concat(table_schema,'.',table_name) as table_name ,engine from information_schema.tables where table_schema = 'test';
    +------------+--------+
    | table_name | engine |
    +------------+--------+
    | test.t     | MyISAM |
    | test.t1    | MyISAM |
    | test.t3    | MyISAM |
    | test.t4    | MyISAM |
    | test.t5    | MyISAM |
    +------------+--------+
    5 rows in set (0.01 sec)
  • 相关阅读:
    Java 中队列的使用
    C# 网络编程之豆瓣OAuth2.0认证具体解释和遇到的各种问题及解决
    Java虚拟机工作原理具体解释
    天将降大任于斯人也,必先苦其心志,劳其筋骨,饿其体肤,空乏其身,行拂乱其所为,所以动心忍性,增益其所不能
    U-BOOT 移植到友善之臂mini2440
    眼下最好的JSP分页技术
    StageFright框架流程解读
    Oracle Hints具体解释
    大学技术类书单
    工作日志2014-07-09
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5630750.html
Copyright © 2011-2022 走看看