2020-04-27 16:26:31
MySQL似乎没有更改数据库名称的语句(也许是我不知道),如果你有数据库服务器的管理权限,可以直接更改一下目录名即可,但如果没有权限,可以通过更改表名达到修改数据库名的目的。
下面是把centos数据库更改为centos_old。
1、新建数据库centos_old.
mysql > create database centos_old;
2、使用select concat拼成所有rename table的语句。
mysql -uroot -p -e "select concat('rename table centos.',table_name,' to centos_old.',table_name,';') from information_schema.TABLES where TABLE_SCHEMA='centos';" > rename_mysql_name.sql
打开rename_mysql_name.sql,把第一行删除。
rename_mysql_name.sql内容大概为:
rename table centos.wp_commentmeta to centos_old.wp_commentmeta; rename table centos.wp_comments to centos_old.wp_comments; rename table centos.wp_forum_forums to centos_old.wp_forum_forums; rename table centos.wp_forum_groups to centos_old.wp_forum_groups; rename table centos.wp_forum_posts to centos_old.wp_forum_posts; rename table centos.wp_forum_threads to centos_old.wp_forum_threads; rename table centos.wp_forum_usergroup2user to centos_old.wp_forum_usergroup2user; rename table centos.wp_forum_usergroups to centos_old.wp_forum_usergroups; rename table centos.wp_links to centos_old.wp_links; rename table centos.wp_options to centos_old.wp_options; rename table centos.wp_postmeta to centos_old.wp_postmeta; rename table centos.wp_posts to centos_old.wp_posts; rename table centos.wp_term_relationships to centos_old.wp_term_relationships; rename table centos.wp_term_taxonomy to centos_old.wp_term_taxonomy; rename table centos.wp_terms to centos_old.wp_terms; rename table centos.wp_usermeta to centos_old.wp_usermeta; rename table centos.wp_users to centos_old.wp_users;
3、执行rename语句
mysql -uroot -p < rename_mysql_name.sql
这样就完成了centos数据库名更改为centos_old的操作。
CentOS使用MySQLbinlog恢复MySQL数据库
05-07
Ubuntu下迁移通过apt安装的MySQL数据库文件目录
07-18
oracle数据库迁移到MySQL的三种方法
04-27
更改MySQL数据文件目录位置
06-05
MySQL笔记之数据备份与还原的使用详解
07-07
CentOS7安装配置PostgreSQL数据库服务器
06-20
Percona Xtrabackup备份MySQL大数据库(完整备份与增量备份)
03-15
PostgreSQL数据库修改表增加主键
07-12
memcached数据库简单配置介绍
05-25
ubuntu安装mongodb数据库服务器
05-29
使用shell脚本结合innobackupex自动备份MySQL innodb数据库
04-06
没有开启Oracle日志归档,紧急情况下如何进行Oracle数据库的冷备份
04-26
记录一次Zabbix-server由于磁盘空间不足迁移数据库的过程
07-19
Docker安装部署MySQL5.7
05-26
『浅入浅出』MySQL及InnoDB存储引擎
07-16
如何实现MySQL的一次一密登录
05-22
快速入门: Compose和Rails
07-02
快速创建一个可读写的Samba Server的shell脚本
07-07
0.Jupyter Notebook快速入门
06-19
Linux chsh更改使用者shell设定命令详解
03-08
HeidiSQL(MySQL服务器数据管理工具) v11.0.0.6055 免费版
10.1M
下载mongodb(开源数据库软件)下载 v4.0.3官方免费版
219M
下载pl sql developer(Oracle数据库存储程序单元的开发软件)2021 免费版
25.2M
下载快速CAD企业版 v2021.2 官方版
17.21M
下载activesync(电脑数据同步工具) v6.1 免费版
22.72MB
下载coreldrawx6(矢量图形快速设计和制作的工具)v6.0 免费版
7 KB
下载后羿采集器(网页数据采集软件) v3.5.3 免费版
45.0M
下载广联达PDF快速看图免费版 v1.9.0.0 官方版
29.9M
下载硬盘保护卡克星(数据破解抹除工具) 1.2 免费版
0.11MB
下载论文格式快速编排助手下载
2.03MB
下载阿里云盘(数据同步软件) v1.4 电脑版
42.4M
下载顶尖数据恢复软件(电脑数据恢复工具) 6.30 破解版
7.5M
下载EasyRecovery 13 下载
12.99MB
下载EverythingToolbar下载
1.3M
下载Print Maestro 4破解版
21.1 MB
下载SoundVolumeView(音量管理软件)下载 v1.90绿色中文版
191KB
下载Valentina Studio 下载
43.06MB
下载activesync下载
22.72MB
下载db commander下载
7.3M
下载easyrecovery pro下载
78.6M
下载