Using phpMyAdmin to batch modify the Mysql data table prefix _ MySQL

Source: Internet
Author: User
Tags how to use phpmyadmin
This article describes how to use phpMyAdmin to modify the Mysql data table prefix in batches. if you want to share a Mysql database with multiple websites, generally, different websites are differentiated by different prefixes. How can I modify the prefix names of an existing database in batches? Export all the modifications before importing them? Or a table? Today, I want to introduce a relatively simple method to modify the table prefix in a database in batches. this method is suitable for modifying databases with the same prefix and a large number of data tables.

In this example, assume that the name is"Www_sdck_cnThe database prefix is"Phpcms _", And modify the prefixes of all qualified tables to"Sdck _".

1. use phpMyAdmin to open the database www_sdck_cn whose prefix is to be modified, and execute the following SQL statement (bold italic must be replaced according to actual needs ):

Select CONCAT ('alter table', table_name, 'Rename to', replace (table_name ,'Phpcms _','Sdck _'),';')

From information_schema.tables

Where TABLE_SCHEMA ='Www_sdck_cnAnd table_name LIKE'Phpcms _% ';

2. click "export" on the page generated by executing the SQL statement, select "custom"-> "display as text directly", and clear the "content separator" as null in CSV format.

3. after the export function is executed, the result window is displayed as follows. copy the content in the text box.

4. go to the database"Www_sdck_cn"SQL execution window, paste the code into the SQL text box, and execute. Check whether the data table has been modified.

Notes

Data operations are risky. back up data before the operation.

Because of software version and other reasons, the operation is for reference only. The author of this article is not liable for any loss or error caused by modifying the database in this 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.