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

日历

<2006年5月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

公告

联系Email: kyo86.dai[at]gmail[dot]com QQ: 285819504

常用链接

随笔档案

Links

搜索

  •  

最新评论

MySQL数据库改名脚本

Posted on 2020-04-04 23:00 魔のkyo 阅读(4146) 评论(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
只有注册用户登录后才能发表评论。