Methods for batch modification of MYSQL data table prefixes using phpMyAdmin _mysql

Source: Internet
Author: User
Tags phpmyadmin

When multiple Web sites share a MySQL database, in order to make the database management is not confused, the general use of different sites using different prefix names to distinguish. And how do you batch modify the prefix name of an existing database? Export all changes and then import? Or is it a table modified by tables? Today I would like to introduce a relatively simple method of batch modification of table prefixes in the database, which is suitable for modifying the same prefix in the database and more data tables.

This example assumes that a table with the prefix "phpcms_" in the database named "WWW_SDCK_CN" is modified and that the prefix for all qualifying tables is modified to "sdck_".

1, with phpMyAdmin open to modify the prefix of the database WWW_SDCK_CN, execute the following SQL statement (which bold italic is required to replace the actual requirements):

Select CONCAT (' ALTER TABLE ', table_name, ' RENAME to ', replace (table_name, 'phpcms_', 'sdck_'), '; ')

From Information_schema.tables

where Table_schema = 'www_sdck_cn' and table_name like 'phpcms_% ';

2, in the execution of the SQL statement generated page click "Export", select "Custom"-> "direct display as text", CSV format, empty "content separator" empty

3, to perform the export function, the results window to the following, copy the contents of the text box

4, into the database "www_sdck_cn" SQL execution window, paste the code into the SQL text box, execute. See if the relevant data sheet has been modified.

Attention matters

Data manipulation is risky, back up your data before you operate.

Because of the software version and other reasons, the operation is for reference only, because this article modifies the database to cause loss or error, the author is not responsible.

Related Article

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.