posts - 225, comments - 62, trackbacks - 0, articles - 0
   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

MySQL数据库改名脚本

Posted on 2020-04-04 23:00 魔のkyo 阅读(4134) 评论(0)  编辑 收藏 引用
转自 https://www.cnblogs.com/weifeng1463/p/9272214.html
#!/bin/bash
#
 假设将sakila数据库名改为new_sakila
#
 MyISAM直接更改数据库目录下的文件即可
mysql -uroot -p123456 -'create database if not exists new_sakila'
 
list_table
=$(mysql -uroot -p123456 -Nse "select table_name from information_schema.TABLES where TABLE_SCHEMA='sakila'")
 
for table in $list_table
do
    mysql 
-uroot -p123456 -"rename table sakila.$table to new_sakila.$table"
done
只有注册用户登录后才能发表评论。