Safe and fast change MySQL database name

Source: Internet
Author: User

1, new database Centos_old.

    1. MySQL > CREATE database centos_old;

2. Use select Concat to spell all rename table statements.

    1. 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

Open the Rename_mysql_name.sql and delete the first line.
The Rename_mysql_name.sql content is about:

  1. Rename table Centos.wp_commentmeta to Centos_old.wp_commentmeta;
  2. Rename table centos.wp_comments to centos_old.wp_comments;
  3. Rename table Centos.wp_forum_forums to centos_old.wp_forum_forums;
  4. Rename table centos.wp_forum_groups to centos_old.wp_forum_groups;
  5. Rename table centos.wp_forum_posts to centos_old.wp_forum_posts;
  6. Rename table Centos.wp_forum_threads to centos_old.wp_forum_threads;
  7. Rename table Centos.wp_forum_usergroup2user to Centos_old.wp_forum_usergroup2user;
  8. Rename table centos.wp_forum_usergroups to centos_old.wp_forum_usergroups;
  9. Rename table Centos.wp_links to centos_old.wp_links;
  10. Rename table Centos.wp_options to centos_old.wp_options;
  11. Rename table Centos.wp_postmeta to Centos_old.wp_postmeta;
  12. Rename table centos.wp_posts to centos_old.wp_posts;
  13. Rename table Centos.wp_term_relationships to centos_old.wp_term_relationships;
  14. Rename table centos.wp_term_taxonomy to centos_old.wp_term_taxonomy;
  15. Rename table centos.wp_terms to centos_old.wp_terms;
  16. Rename table Centos.wp_usermeta to Centos_old.wp_usermeta;
  17. Rename table Centos.wp_users to centos_old.wp_users;

3. Execute Rename Statement

    1. Mysql-uroot-p < Rename_mysql_name.sql

This completes the operation of changing the CentOS database name to Centos_old.

Safe and fast change MySQL database name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.