您的位置:首页 > 数据库 > MySQL

mysql5.7.1.log数据库改名

2020-07-07 14:25 826 查看

精选30+云产品,助力企业轻松上云!>>>

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/

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息