shop-old.sh 443 B

1234567891011
  1. #!/bin/bash
  2. # 假设将sakila数据库名改为new_sakila
  3. # MyISAM直接更改数据库目录下的文件即可
  4. mysql -uroot -pXTZ@shop@951688 -e 'create database if not exists xyzshopold'
  5. list_table=$(mysql -uroot -pXTZ@shop@951688 -Nse "select table_name from information_schema.TABLES where TABLE_SCHEMA='xyzshop'")
  6. for table in $list_table
  7. do
  8. mysql -uroot -pXTZ@shop@951688 -e "rename table xyzshop.$table to xyzshopold.$table"
  9. done