本篇内容主要讲解“MySQL中如何快速更改数据库名称”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“MySQL中如何快速更改数据库名称”吧!
mysql > create database centos_old;
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;
mysql -uroot -p
这样就完成了centos数据库名更改为centos_old的操作。
到此,相信大家对“MySQL中如何快速更改数据库名称”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。