mysql5.7.1.log数据库改名

1.a -->b

#!/bin/bash
#先判断新数据库是否存在,要是不存在就创建。
#列出老数据库下都有那些表,其中N和s参数起到的作用是格式化,有点类似于Oracle下sqlplus里的pag
#用for循环来rename。

/bin/mysql -uroot -pjjjjj -h10.0.0.22 -e 'create database if not exists wxqyh_test_0704'
list_table=$(/bin/mysql -uroot -pjjjj -h10.0.0.22 -Nse "select table_name from information_schema.TABLES where TABLE_
SCHEMA='wxqyh_test'")

for table in $list_table
do
    #echo $table
    /bin/mysql -uroot -pjjjj -h10.0.0.22  -e "rename table wxqyh_test.$table to wxqyh_test_0704.$table"
done
[root@VM_0_134_centos 0704]# 

 参考:http://blog.itpub.net/20893244/viewspace-2147259/

posted @ 2020-07-04 16:23  littlevigra  阅读(435)  评论(1编辑  收藏  举报