MySQL在5.1引入了一个rename database操作,但在MySQL5.1.23后又不支持这个命令。可以说是一个实验性的功能,没有在生产中支持过(mysql-5.1 release在mysql-5.1.30),那么生产中我们有时为了追求完美需要改一下库名。怎么操作呢?
这里提供一个变通的方法。
1. 创建出新库名:
mysql>create database db_v2; mysql>create database db_v2;
2.生成rename语句,从olddb里迁移,我这里olddb里sbtest;
mysql>select concat("rename table ",table_schema,".",table_name," to db_v2.",table_name,";") into outfile '/tmp/rename_to_db_v2.sql' from information_schema.tables where table_schema='sbtest';
mysql>select concat("rename table ",table_schema,".",table_name," to db_v2.",table_name,";") into outfile '/tmp/rename_to_db_v2.sql' from information_schema.tables where table_schema='sbtest';
3.执行生成的sql
基于ECSHOP2.7.2制作,模板使用的是早期的凡客模板。整站大气,清爽。适合综合,鞋子,服饰类商城使用。具体安装方法在程序包中有说明,在使用之前请看下。 大体方法:1.上传程序至网站根目录,访问:域名/diguo (用户名:admin 密码:123456)2.设置好数据库信息,然后恢复数据,数据目录在www.shopex5.com下.3.修改data目录下的config数据库配置文件。4.登陆
mysql>source /tmp/rename_to_db_v2.sql mysql>source /tmp/rename_to_db_v2.sql
就这么简单可以搞定了。
Good luck!









