Heim  >  Artikel  >  Datenbank  >  So ändern Sie schnell den Datenbanknamen in MySQL

So ändern Sie schnell den Datenbanknamen in MySQL

PHPz
PHPznach vorne
2023-05-26 21:46:042537Durchsuche

So ändern Sie schnell den Datenbanknamen in MySQL

1. Erstellen Sie eine neue Datenbank centos_old.

mysql > create database centos_old;

2. Verwenden Sie select concat, um alle Umbenennungstabellenanweisungen zu buchstabieren.

    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

Öffnen Sie rename_mysql_name.sql und löschen Sie die erste Zeile. Der Inhalt von

rename_mysql_name.sql lautet ungefähr:

   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. Führen Sie die Umbenennungsanweisung aus

mysql -uroot -p

Damit ist der Vorgang zum Ändern des Centos-Datenbanknamens in centos_old abgeschlossen.

Das obige ist der detaillierte Inhalt vonSo ändern Sie schnell den Datenbanknamen in MySQL. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Dieser Artikel ist reproduziert unter:yisu.com. Bei Verstößen wenden Sie sich bitte an admin@php.cn löschen