>  기사  >  데이터 베이스  >  MySQL에서 데이터베이스 이름을 빠르게 변경하는 방법

MySQL에서 데이터베이스 이름을 빠르게 변경하는 방법

PHPz
PHPz앞으로
2023-05-26 21:46:042537검색

MySQL에서 데이터베이스 이름을 빠르게 변경하는 방법

1. 새 데이터베이스 centos_old.

mysql > create database centos_old;

2를 생성하여 모든 이름 바꾸기 테이블 문을 작성합니다.

    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 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 yisu.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제