【Mysql】改数据库库名操作
发表于:2026-10-31 作者:千家信息网编辑
千家信息网最后更新 2026年10月31日,MySQL在5.1引入了一个rename database操作,但在MySQL5.1.23后又不支持这个命令。可以说是一个实验性的功能,没有在生产中支持过(mysql-5.1 release在mysq
千家信息网最后更新 2026年10月31日【Mysql】改数据库库名操作
[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 执行即可
原文地址:http://wubx.net/tips-mysql-rename-database/
MySQL在5.1引入了一个rename database操作,但在MySQL5.1.23后又不支持这个命令。可以说是一个实验性的功能,没有在生产中支持过(mysql-5.1 release在mysql-5.1.30),那么生产中我们有时为了追求完美需要改一下库名。怎么操作呢?
这里提供一个变通的方法。
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 执行即可
点击(此处)折叠或打开
- mysql> source /tmp/rename_to_db_v2.sql;
原文地址:http://wubx.net/tips-mysql-rename-database/
支持
产中
功能
原文
命令
地址
实验性
方法
生产中
说是
变通
实验
生产
数据
数据库
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
保险科技 互联网保险
互联网科技公司的优势
互联网科技财经
奇酷互联网络科技
亿账通互联网科技
友谊互联网络科技
苏州大垚互联网科技
互联网科技美容
互联网科技咨询
互联网科技公司名称
科技类的互联网平台
现代科技和互联网有关系吗
随着互联网科技发展
彤创互联网科技有限公司
中国科技创新与世界互联网大会
科技大学互联网
互联网科技数字货币
江苏互联网智能科技产品出厂价
如何强化互联网金融科技
互联网 科技节活动 微视频大赛
云南咖啡
互联网电商科技
互联网科技深圳
互联网科技公司电话
礼当家互联网科技
群盈汇互联网科技有限公司
山东大美朱楼互联网科技有限公司
艺电能源互联网科技有限公司招聘
深圳互联网科技园地址
盐城市攀科互联网科技有限公司
- 上一篇
innobackupex:Error:xtrabackup child process has died at /usr/bin/innobackupex
使用innobackupex进行数据库备份,报如下错误:innobackupex --compress --parallel=4 --user=root --password=yoon /export
- 下一篇
数字化企业发展为什么选择SAP?
社会发展到今天,每个人的生活方式,都是通过网络把人与人密切绑定在一起;明天,或许网络会让人与物、物与物之间、企业管理与生产、销售等职能部门更智能地绑定在一起。显然,人还是主角,数据是通途,而SAP则是