摘自:https://blog.csdn.net/tjcwt2011/article/details/79451764
以下为脚本:
#!/bin/bash # 假设将dssj数据库名改为new_dssj # MyISAM直接更改数据库目录下的文件即可 mysql -uroot -p123456 -e 'create database if not exists new_dssj' list_table=$(mysql -uroot -p123456 -Nse "select table_name from information_schema.TABLES where TABLE_SCHEMA='dssj'") for table in $list_table do mysql -uroot -p123456 -e "rename table dssj.$table to new_dssj.$table" done