mysql5.7.1.log数据库改名

对着背影说爱祢 提交于 2020-08-13 08:55:43

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/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!