网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

【Mysql】改数据库库名操作

MySQL在5.1引入了一个rename database操作,但在MySQL5.1.23后又不支持这个命令。可以说是一个实验性的功能,没有在生产中支持过(mysql-5.1 release在mysql-5.1.30),那么生产中我们有时为了追求完美需要改一下库名。怎么操作呢?
这里提供一个变通的方法。
1. 创建出新库名:

此处)折叠或打开
  1. mysql> select concat("rename table ",table_schema,".",table_name," to testbak.",table_name,";") into outfile '/tmp/rename_to_db_v2.sql' from information_schema.tables where table_schema='test';

[root@host-192-168-1-56 ~]# more /tmp/rename_to_db_v2.sql   
rename table test.bc_dbfsxiang to testbak.bc_dbfsxiang;
rename table test.bc_dkfsxiang to testbak.bc_dkfsxiang;
rename table test.bc_dkytxiang to testbak.bc_dkytxiang;
rename table test.bc_gzffxiang to testbak.bc_gzffxiang;
rename table test.bc_option_map to testbak.bc_option_map;
rename table test.bc_qylxxiang to testbak.bc_qylxxiang;
rename table test.bc_service_city to testbak.bc_service_city;
rename table test.bc_service_qi_city to testbak.bc_service_qi_city;
rename table test.bc_wffkhyxiang to testbak.bc_wffkhyxiang;
rename table test.bc_wffkzyxiang to testbak.bc_wffkzyxiang;
rename table test.bc_xindai to testbak.bc_xindai;
rename table test.bc_xindai_fields_v to testbak.bc_xindai_fields_v;
rename table test.bc_xindai_geren to testbak.bc_xindai_geren;
rename table test.bc_xindai_qiye to testbak.bc_xindai_qiye;
rename table test.bc_xyjlxiang to testbak.bc_xyjlxiang;
rename table test.bc_zyyqxiang to testbak.bc_zyyqxiang;
rename table test.fake_names to testbak.fake_names;
rename table test.idmap to testbak.idmap;
rename table test.sbtest to testbak.sbtest;
rename table test.tbUser to testbak.tbUser;
rename table test.test to testbak.test;
rename table test.test2 to testbak.test2;


3  执行即可

点击(此处)折叠或打开

成都创新互联2013年开创至今,先为河南等服务建站,河南等地企业,进行企业商务咨询服务。为河南企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

  1. mysql> source /tmp/rename_to_db_v2.sql;





原文地址:http://wubx.net/tips-mysql-rename-database/


新闻标题:【Mysql】改数据库库名操作
文章起源:http://bjjierui.cn/article/psdjjo.html