当前位置:Gxlcms > 数据库问题 > 修改mysql的数据库名字

修改mysql的数据库名字

时间:2021-07-01 10:21:17 帮助过:42人阅读

修改的原理就是创建一个新的数据库然后把所有的表rename。具体就看下面的脚本吧。我是要把download这个数据库的名字改成downloadv2

#!/bin/bash
mysql -uroot -p1q2w3e4r -e ‘create database if not exists downloadv2‘
list_table=$(mysql -uroot -p1q2w3e4r -Nse "select table_name from information_schema.TABLES where TABLE_SCHEMA=‘download‘")
for table in $list_table
do
mysql -uroot -p1q2w3e4r -e "rename table download.$table to downloadv2.$table"
done


本文出自 “技术为王” 博客,请务必保留此出处http://wangzhenyu.blog.51cto.com/2996939/1660544

修改mysql的数据库名字

标签:mysql   database   change name   

人气教程排行