ホームページ  >  記事  >  データベース  >  MySQL でデータベース名をすばやく変更する方法

MySQL でデータベース名をすばやく変更する方法

PHPz
PHPz転載
2023-05-26 21:46:042537ブラウズ

MySQL でデータベース名をすばやく変更する方法

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

これで、centos データベース名を centos_old に変更する操作は完了です。

以上がMySQL でデータベース名をすばやく変更する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事はyisu.comで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。