1, new database Centos_old.
- MySQL > CREATE database centos_old;
2. Use select Concat to spell all rename table statements.
- 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:
- 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. Execute Rename Statement
- 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