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.